im trying to get the data from the database. in the first loop it can get the data but in the second loop it will pop up a error saying:
Object reference not set to an instance of an object.
heres my code:
da = New SqlDataAdapter("SELECT refno, pono FROM transmital WHERE refname = '" & txtTransRefName.Text & "' ORDER BY refno", DB.DARConString)
ds = New DataSet
da.Fill(ds, "refnam")
xlWb = xlApp.Workbooks.Add()
For i = 0 To ds.Tables("refnam").Rows.Count - 1
**'this line gets the error** refnum = ds.Tables("refnam").Rows(i).Item("refno").ToString.Trim
ponum = ds.Tables("refnam").Rows(i).Item("pono").ToString.Trim
Next
any help will be highly appreciated. Thank you