B
Bruno Alexandre
Hi guys...
I'm stuck!
I'm devoloping this program and everything was doing fine, until now!
This is what happends.
<my VB.NET 2.0 code>
Sub getUtenteIntoVariables(ByVal idUtente As String)
Dim conn As New SqlClient.SqlConnection(connString)
Dim cmd As New SqlClient.SqlCommand
Dim reader As SqlClient.SqlDataReader
Dim strSQL As String
Try
strSQL = "SELECT tnome FROM utiUtentes"
With cmd
.CommandText = strSQL
.CommandType = CommandType.Text
.Connection = conn
End With
conn.Open()
reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.
Uten_Nome.Text = reader.Item("tnome").ToString
conn.Close()
Catch ex As Exception
MsgBox("Error: " & vbCrLf & ex.Message & vbCrLf & vbCrLf & "SQL Query: "
& vbCrLf & strSQL & vbCrLf & vbCrLf)
Finally
'Beep()
End Try
End Sub
</my VB.NET 2.0 code>
When it gets into this line Uten_Nome.Text = reader.Item("tnome").ToString
the program breaks and shows me this message:
"invalid attempt to read when no data is present"
I know that I have date in it, I can see with GetOrdinal("columnname")
method....
What am I doing wrong?
I'm stuck!
I'm devoloping this program and everything was doing fine, until now!
This is what happends.
<my VB.NET 2.0 code>
Sub getUtenteIntoVariables(ByVal idUtente As String)
Dim conn As New SqlClient.SqlConnection(connString)
Dim cmd As New SqlClient.SqlCommand
Dim reader As SqlClient.SqlDataReader
Dim strSQL As String
Try
strSQL = "SELECT tnome FROM utiUtentes"
With cmd
.CommandText = strSQL
.CommandType = CommandType.Text
.Connection = conn
End With
conn.Open()
reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.
Uten_Nome.Text = reader.Item("tnome").ToString
conn.Close()
Catch ex As Exception
MsgBox("Error: " & vbCrLf & ex.Message & vbCrLf & vbCrLf & "SQL Query: "
& vbCrLf & strSQL & vbCrLf & vbCrLf)
Finally
'Beep()
End Try
End Sub
</my VB.NET 2.0 code>
When it gets into this line Uten_Nome.Text = reader.Item("tnome").ToString
the program breaks and shows me this message:
"invalid attempt to read when no data is present"
I know that I have date in it, I can see with GetOrdinal("columnname")
method....
What am I doing wrong?