ありがとう、私は MAX ステートメントを使用しましたが、エラーは返されませんが、それでも機能しない理由がわかりません。私のコードを以下に示します。
Protected Sub txtuserID_TextChanged(sender As Object, e As System.EventArgs) Handles txtuserID.TextChanged
Dim strConnection As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=E:\LostPropertyProject\App_Data\LostPropertyDatabase.mdf;Integrated Security=True;User Instance=True"
'Establish SQL Connection
Dim con As New SqlConnection(strConnection)
'Open database connection to connect to SQL Server
con.Open()
'Data table is used to bind the resultant data
Dim dtusers As New DataTable()
'Create a new data adapter based on the specified query.
Dim comm As New SqlCommand
comm.CommandText = "SELECT MAX(UserID) FROM tblUser"
comm.Connection = con
Dim MaxUserID As Object = comm.ExecuteScalar()
con.Close()
End Sub
また、ページが読み込まれるとすぐにテキスト ボックスに userID が表示されるようにします。どうすればそれを行うことができますか?そして、私の質問に答えてくれたすべての人に感謝します:)どうもありがとう