Results 1 to 3 of 3

Thread: submit dataset to database

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2001
    Location
    Belgium
    Posts
    5

    Question submit dataset to database

    hi everyone,

    i'm a newbee on this forum, and looking for help
    This is my problem:
    I have tried to fill a dataset from a database
    this is done bij a stored procedure
    (Getting data from multiple tables!)

    Here is the code for that part:
    ..........

    ComCD = New OleDbCommand("cmdTwoInOne", MyConn)

    Debug.WriteLine("test select: " & intAr_ID)
    ComCD.Parameters.Add("@ArtiestID", OleDbType.Integer)
    ComCD.Parameters("@ArtiestID").Value = intAr_ID
    ComCD.CommandType = CommandType.StoredProcedure
    daCDs.SelectCommand = ComCD
    daCDs.FillSchema(dsCD, SchemaType.Source, "tblCD")
    daCDs.Fill(dsCD, "tblCD")
    .......

    When i have the dataset i want to update a row in it
    no problem so far.

    But when i want to submit the changes of the dataset to the database...it goes wrong
    Here is the code how i do that:

    Public Sub UpdateCD(ByVal test As DataSet)

    If MyConn.State = ConnectionState.Open Then
    Else
    MyConn.Open()
    End If
    Dim custCD As OleDbCommandBuilder = New OleDbCommandBuilder(myCommand)
    myCommand.Update(test, "tblCD")

    ......
    in the last rule it goes wrong: mycommand.Update(test,"tblCD")
    I'm getting this error:
    Value null was found where an instance of an object was required.

    I don't no why?
    Is it because there are combined tables in the dataset?
    If so where can i find information on the net on updating database with combined tables?

    Can somebody please help me out!

    Thanx guys...
    THX in advance

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    maybe a dumb question, but you are passing the dataset into the Update Sub right? Just trying the easy questions first.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2001
    Location
    Belgium
    Posts
    5
    yes i pass it trough the Update....
    But i found the problem and i made a work a round
    I loaded the dataset with a stored procedure that create combined tables...
    i made changes to this dataset and then i wanted to update
    de database(DB) table...
    But the table in de dataset does not exist in de DB....
    I guess this is the problem....

    As work around i updated the record directly to the DB and
    read back the data into the dataset....

    this is not the right way but......

    I still have a long way to go in .NET!!
    If there is a way to update a dataset (to DB) with combined tables,
    i would like to hear this....
    The resources on www don't tel anything about it!!!!

    Thx Cander for your reply
    THX in advance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width