テーブルから最後の ID を取得して表示する必要があります。Scope_Identity() を試しましたが、何とか取得できませんでした。メッセージ ボックスには何も表示されません。空です。ここに私の現在のコードがあります:
Try
myConn.ConnectionString = "Data Source=192.168.2.222;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=sa;"
myConn.Open()
myCmd = New System.Data.SqlClient.SqlCommand("SELECT SCOPE_IDENTITY AS LastId FROM customers", myConn)
oResult = myCmd.ExecuteScalar()
If oResult IsNot Nothing Then
MsgBox(oResult.ToString)
Else
MsgBox("No Record Found")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
myConn.Close()
End Try