Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

There is no row at position 1

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
getting an error saying "There is no row at position 1" using the below code to fill in a data grid. weird thing is, I only get the error every once in a while. can't pin point why the error is happening.

any help would be appreciated


Dim sql As String = "SELECT MyFields from MyTable where Field1 = '" & l8.Text & "' ORDER BY Field1"
Dim connection As New SqlConnection(strcn)
connection.Open()
sCommand = New SqlCommand(sql, connection)
sAdapter = New SqlDataAdapter(sCommand)
sBuilder = New SqlCommandBuilder(sAdapter)
sDs = New DataSet()
sAdapter.Fill(sDs, "Table")
sTable = sDs.Tables("Table")

dg1.DataSource = sDs.Tables("Table")

l14.Text = dg1.Rows.Count




 

What line throws the error?

Do you have any error trapping code (i.e., Try...Catch)?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top