Insertcommand problem

Discussion in 'Databases' started by Geo, May 3, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Geo

    Geo

    I'm up against a wall trying to learn data use in ASP.Net. I can retrieve data OK but can't INSERT (or most likely UPDATE either). I'm using the data connections and adapters in VS.NET, and in spite of a mountain of books, can't get a handle on it.

    Can someone put me on the right path?

    When attempting to do an insert, I get this message:
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</font id="red">

    refering to: dbaProblems.InsertCommand.CommandText = strSQL

    dcVeh is an oledbdataconnector
    dbaProblems is an oledbdataadapter
    dsVP is a dataset

    my code:
    Dim strSQL As String
    Dim myRow As Data.DataRow

    dbcVeh.Open()
    dbaProblems.Fill(DsVP)

    strSQL = "INSERT INTO tblProblems ( PRB_VID, PRB_Driver, RB_Driver_Rem )"

    myRow = DsVP.Tables("tblProblems").NewRow
    myRow("PRB_VID") = lblID.Text
    myRow("PRB_Driver") = lblDriver.Text
    myRow("PRB_Driver_Rem") = txtRemarks.Text
    DsVP.Tables("tblProblems").Rows.Add(myRow)

    dbaProblems.InsertCommand.CommandText = strSQL
    dbaProblems.Update(DsVP, "tblproblems")</font id="red">
    dbcVeh.Close()
    [xx(]

    Geo B
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page