G
Guest
I am getting this error when the DataReader returns a Null Value.
"Invalid attempt to read when no data is present."
It works fine as long as there is a string. What is the NZ() function in VB.Net?
or what would be the best way to handle this?
--
Thank You, Leo
Public Function GetNotes(ByVal NoteType As String)
Dim conSql As New SqlClient.SqlConnection
conSql.ConnectionString = "Integrated Security = True;" & _
"Data Source = TWSQL;Initial Catalog = HomeBASE;"
Dim cmd As SqlCommand = New _
SqlCommand("Select Note FROM HomeBASE.dbo.Notes INNER JOIN " & _
"HomeBASE.dbo.NoteType_ID ON HomeBASE.dbo.Notes.NoteType_ID = HomeBASE.dbo.NoteType_ID.NoteType_ID " & _
"where HomeBASE.dbo.NoteType_ID.description =" & "'" & NoteType & "'" & "and HomeBASE.dbo.Notes.Job_ID = TWCUSTOM.dbo.fn_TW_GetCurrentJobID()", conSql)
conSql.Open()
Dim drSqlDataReader As SqlDataReader = cmd.ExecuteReader()
drSqlDataReader.Read()
Dim Notes = drSqlDataReader.Item(0).ToString()
drSqlDataReader.Close()
conSql.Close()
Return Notes
End Function
"Invalid attempt to read when no data is present."
It works fine as long as there is a string. What is the NZ() function in VB.Net?
or what would be the best way to handle this?
--
Thank You, Leo
Public Function GetNotes(ByVal NoteType As String)
Dim conSql As New SqlClient.SqlConnection
conSql.ConnectionString = "Integrated Security = True;" & _
"Data Source = TWSQL;Initial Catalog = HomeBASE;"
Dim cmd As SqlCommand = New _
SqlCommand("Select Note FROM HomeBASE.dbo.Notes INNER JOIN " & _
"HomeBASE.dbo.NoteType_ID ON HomeBASE.dbo.Notes.NoteType_ID = HomeBASE.dbo.NoteType_ID.NoteType_ID " & _
"where HomeBASE.dbo.NoteType_ID.description =" & "'" & NoteType & "'" & "and HomeBASE.dbo.Notes.Job_ID = TWCUSTOM.dbo.fn_TW_GetCurrentJobID()", conSql)
conSql.Open()
Dim drSqlDataReader As SqlDataReader = cmd.ExecuteReader()
drSqlDataReader.Read()
Dim Notes = drSqlDataReader.Item(0).ToString()
drSqlDataReader.Close()
conSql.Close()
Return Notes
End Function