creating empty dataset

yaniv

Well-known member
Joined
Apr 15, 2002
Messages
162
Location
israel
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 didnt create the first table), the dataset return nothing and I get the massage "theres no row in position 0") . I tried to create a "virtual" table, like this:

Code:
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 "theres no row in position 0" !!

Do you have a solution for this problem?
 
I think you want to check the Tables.Count property first. Try something like:
Code:
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
 
Back
Top