Dim MaxCusID As String = Val("")
objCmd = New SqlCommand(strSQL, objConn)
Dim dtAdapter As New SqlDataAdapter
strSQL = "Select MAX(CusID) As MaxCusID from Customer"
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
Session("CusID") = CusID
Dim MaxCusID As String = Val("")
objCmd = New SqlCommand(strSQL, objConn)
strSQL = "Select MAX(CusID) As MaxCusID from Customer"
With objCmd
.Connection = objConn
.CommandType = CommandType.Text
.CommandText = strSQL
End With
Session("CusID") = objCmd.ExecuteScalar <<< ลองเอาไปแก้ดู
ได้แล้วครับเปลี่ยนคำสั่ง ใช้select max แล้วมีปัญหา เลยใช้เเบบนี้เเล้วได้ Code (VB.NET)
objCmd = New SqlCommand(strSQL, objConn)
strSQL = "Select top 1 CusID from Customer order by CusID DESC"
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
Dim reader As SqlDataReader = objCmd.ExecuteReader()
reader.Read()
Dim MaxCusID As String = reader("CusID")
reader.Close()
Session("CusID") = MaxCusID