Hi,
Below is the code snippet where i would like to display a msgbox if there are no matching records. I always get a NullReferenceEx ception at iRows = ds.Tables("dt") .Rows.Count
Please help me solve it
Thanks
Try
Dim sql As String = "Select * from property where accountno = " & id.ToString '& "%'"
Dim sa As MySqlDataAdapte r = New MySqlDataAdapte r
sa.SelectComman d = New MySqlCommand(sq l, conn)
Dim ds As New DataSet
Dim dt As DataTable = New DataTable("prop erty")
Dim iRows As Integer = New Integer
Try
dt.Columns.Add( "accountno" )
ds.Tables.Add(d t)
iRows = ds.Tables("dt") .Rows.Count
MsgBox(iRows, , "Number of datarows: iRows")
'test the value of iRow
If iRows > 0 Then
'No datarows present
Else
'at least one datarow present
End If
Below is the code snippet where i would like to display a msgbox if there are no matching records. I always get a NullReferenceEx ception at iRows = ds.Tables("dt") .Rows.Count
Please help me solve it
Thanks
Try
Dim sql As String = "Select * from property where accountno = " & id.ToString '& "%'"
Dim sa As MySqlDataAdapte r = New MySqlDataAdapte r
sa.SelectComman d = New MySqlCommand(sq l, conn)
Dim ds As New DataSet
Dim dt As DataTable = New DataTable("prop erty")
Dim iRows As Integer = New Integer
Try
dt.Columns.Add( "accountno" )
ds.Tables.Add(d t)
iRows = ds.Tables("dt") .Rows.Count
MsgBox(iRows, , "Number of datarows: iRows")
'test the value of iRow
If iRows > 0 Then
'No datarows present
Else
'at least one datarow present
End If
Comment