hi!
I am trying to excute sql command and get result.
The following code gives me an error, 'invalid data attempt when no data present'
The result that I am looking for is integer. Do I need to use something other than SqlDataReader?
Thanks in advance
----------------------------------------------------------
Try
objConn.Open()
Dim objCmd As SqlCommand = objConn.CreateCommand()
objCmd.CommandText = _
"SELECT max(SessionNum) FROM TreadMills WHERE UserID = '" & ID & "'"
Dim dataReader As SqlDataReader = objCmd.ExecuteReader()
MessageBox.Show("dataReader is " & dataReader.GetInt32(0))<-----------------error
Catch ex As Exception
MessageBox.Show("Error msg " & ex.Message)
-------------------------------------------------------
I am trying to excute sql command and get result.
The following code gives me an error, 'invalid data attempt when no data present'
The result that I am looking for is integer. Do I need to use something other than SqlDataReader?
Thanks in advance
----------------------------------------------------------
Try
objConn.Open()
Dim objCmd As SqlCommand = objConn.CreateCommand()
objCmd.CommandText = _
"SELECT max(SessionNum) FROM TreadMills WHERE UserID = '" & ID & "'"
Dim dataReader As SqlDataReader = objCmd.ExecuteReader()
MessageBox.Show("dataReader is " & dataReader.GetInt32(0))<-----------------error
Catch ex As Exception
MessageBox.Show("Error msg " & ex.Message)
-------------------------------------------------------