There is no row at position 0???

G

Guest

Can someone please tell me why I keep getting the error!

There is no row at position 0
Dim row As DataRow = table.Rows(0)

I know it has something to do with the value of rowID because if I set rowID
as a fixed value rather than using a querystring it works!

Any ideas???

Thanks

Private rowID As Integer

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Get Text for Editor
If Not Page.IsPostBack Then
FreeTextBox1.Text = GetDocument()
End If
rowID = Request.QueryString(ID)
End Sub 'Page_Load

Public Sub Button_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
UpdateDocument(FreeTextBox1.Text)
End Sub 'Button_Click

Private Function GetDocument() As String
Dim ds As DataSet = GetDataSet(("SELECT * FROM tblPageContent WHERE
pageID=" + rowID.ToString()))
Dim table As DataTable = ds.Tables(0)
Dim row As DataRow = table.Rows(0)
Dim doc As String = row("content").ToString()
Return doc
End Function 'GetDocument
 
J

Juan T. Llibre

hat code looks like the FreeTextBox code at
http://www.freetextbox.com/forums/ShowPost.aspx?PostID=613

You might want to compare your version of that code
with the published version at that page, which works,
and see where you made a transcription or conceptual
mistake.

Offhand, I see that DonnyEMU declared

Private rowID As Integer = 1

so that there wouldn't be a reference
to an empty row in the initial call.




Juan T. Llibre
ASP.NET MVP
===========
 
J

Juan T. Llibre

re:
so that there wouldn't be a reference
to an empty row in the initial call.

Oops...that should be :
so that there wouldn't be a reference
to a non-existent row in the initial call.




Juan T. Llibre
ASP.NET MVP
===========
 
M

Marina

You are calling GetDocument before you assign rowID. So rowID is always 0
when this function gets called, and your query does not return a result.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top