Last active
April 29, 2021 01:15
-
-
Save muramoto1041/04f28e60026a29f69f81fe7184d78504 to your computer and use it in GitHub Desktop.
Get_NewID.aspx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Protected Sub S_GetID(qTBL As String) | |
'Azure | |
Dim strSQL As String | |
Dim cnnStr As String = ConfigurationManager.AppSettings("apps_BariSpDT_Kava") | |
Dim cnn As SqlConnection = New SqlConnection(cnnStr) | |
Dim sqlcmdSelect As SqlCommand = New SqlCommand() | |
Dim adpt As SqlDataAdapter = New SqlDataAdapter() | |
Dim dsDataSet As DataSet = New DataSet | |
sIDNew = 0 | |
sqlcmdSelect.Connection = cnn | |
sqlcmdSelect.CommandTimeout = 15 | |
strSQL = "SELECT MAX([IDCard]) As IDmax FROM " & qTBL & " ;" | |
sqlcmdSelect.CommandText = strSQL | |
adpt.SelectCommand = sqlcmdSelect | |
Try | |
adpt.Fill(dsDataSet) | |
Catch ex As Exception | |
cnn.Close() | |
lblMsg.Text = " データベースアクセスに失敗しました。" | |
GoTo LBL_EXIT | |
End Try | |
If dsDataSet.Tables(0).Rows.Count > 0 Then | |
With dsDataSet.Tables(0).Rows(0) | |
If .IsNull("IDmax") = False Then | |
sIDNew = .Item("IDmax") + 1 | |
Else | |
sIDNew = 1 | |
End If | |
End With | |
Else | |
'lblMsg.ForeColor = Drawing.Color.Red | |
'lblMsg.Text = " デーが見つかりません。" | |
End If | |
LBL_EXIT: | |
cnn = Nothing | |
sqlcmdSelect = Nothing | |
adpt = Nothing | |
dsDataSet = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment