I'm running this code:
Dim dvTest As DataView
Dim cnn As SqlConnection = Utilities.GetMyConnectionString
Dim cmd As New SqlCommand("mystoredprocedure", cnn)
Dim dSet As New DataSet
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandTimeout = 2000
Dim da As New SqlDataAdapter(cmd)
Try
da.Fill(dSet, "Accounts")
dvTest = dSet.Tables("Accounts").DefaultView
'Filter by one ID
dvTest.RowFilter = String.Format("ID='{0}'", (Utilities.PadRight(Me.ID, 15)))
sb.Append(dvTest.Item(0).Item(2).ToString) 'build into string
sb.ToString
Catch ex As Exception
Throw
End Try
But I get the error:
Index 0 is not non-negative and below total rows count.
What is strange is that it is that the stored procedure is returning more than 1 record in the dataview, but somewhere it's dieing out.... any ideas?
Chris
ASKER
So to avoid after the row filter I put
If dvTest.Count = 1 Then '(there is a match)
'Build string
Else
'Don't build string
End If
I'll give you the points for effort!
Chris