Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i"m creating an app. that supposed to give the user the opportunity to build himself a table and to edit it in the future.

 

The problem is that in the first reading of the dataset (when the user didn't create the first table), the dataset return nothing and I get the massage "there's no row in position 0") . I tried to create a "virtual" table, like this:

 

if myDS.tables(0).rows.count <=0 then

Dim dr As DataRow
       Dim table1 As DataTable

       table1 = myDS.Tables.Add("Table1")
for o = 0 to 18 ' I have 19 colums in the final tables
       table1.Columns.Add()
next

dr = table1.NewRow()

for o = 0 to 18
       dr(o) = ""
       table1.Rows.Add(dr)
next o

 

But I still get the "there's no row in position 0" !!

 

Do you have a solution for this problem?

  • *Experts*
Posted

I think you want to check the Tables.Count property first. Try something like:

if myDS.Tables.Count = 0 Then
       Dim dr As DataRow
       Dim table1 As DataTable
       table1 = myDS.Tables.Add("Table1")
       for o = 0 to 18 ' I have 19 colums in the final tables
               table1.Columns.Add()
       next
       
       dr = table1.NewRow()

       for o = 0 to 18
               dr(o) = ""
               table1.Rows.Add(dr)
       next o
end if

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...