where is your DataSet object??dim ds as new DataSet
YourDataAdpater.Fill(ds)
...
myDataRow=ds.tables(Table1).newrow()

解决方案 »

  1.   

    for(int i=0; i <bb.Count; i++)
    {
    DataRow dr=dTable.NewRow();
    dr[0]=bb[i].ToString();
    dTable.Rows.Add(dr);
    }
      

  2.   

    ' Create a DataSet with one table, two columns, and ten rows.
        Dim ds As New DataSet("myDataSet")
        Dim t As New DataTable("Items")    ' Add tables to the DataSet
        ds.Tables.Add(t)    ' Create and add two columns to the DataTable
        Dim c1 As New DataColumn("id", Type.GetType("System.Int32"), "")
        c1.AutoIncrement = True
        Dim c2 As New DataColumn("Item", Type.GetType("System.Int32"), "")
        t.Columns.Add(c1)
        t.Columns.Add(c2)    ' DataColumn array to set primary key.
        Dim keyCol(1) As DataColumn    ' Set primary key column.
        keyCol(0) = c1
        t.PrimaryKey = keyCol    ' Add RowChanged event handler for the table.
        AddHandler t.RowChanged, AddressOf Row_Changed    ' Add ten rows.
        Dim i As Integer
        Dim r As DataRow    For i = 0 To 9
            r = t.NewRow()
            r("Item") = i
            t.Rows.Add(r)
        Next i    ' Accept changes.
        ds.AcceptChanges()
        PrintValues(ds, "Original values")    ' Create a second DataTable identical to the first
        ' with one extra column using the Clone method.
        Dim t2 As New DataTable
        t2 = t.Clone()    ' Add column.
        t2.Columns.Add("extra", Type.GetType("System.String"))    ' Add two rows. Note that the id column can't be the 
        ' same as existing rows in the DataSet table.
        Dim newRow As DataRow
        newRow = t2.NewRow()
        newRow("id") = 12
        newRow("Item") = 555
        newRow("extra") = "extra Column 1"
        t2.Rows.Add(newRow)
        
        newRow = t2.NewRow()
        newRow("id") = 13
        newRow("Item") = 665
        newRow("extra") = "extra Column 2"
        t2.Rows.Add(newRow)    ' Merge the table into the DataSet.
        Console.WriteLine("Merging")
        ds.Merge(t2, False, MissingSchemaAction.Add)
        PrintValues(ds, "Merged With Table, Schema Added")
      

  3.   

    myDataRow=DataSet.tables(Table1).newrow()这行是错的
    应该是myDataRow=DataSet.Tables["Table1"].NewRow();
    注意:DataSet.Tables是一个类数组,并注意大小写