Results 1 to 4 of 4

Thread: another weird problem...please help!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    125

    Unhappy another weird problem...please help!

    I have already used this code in my other form and it works perfectly well...when I used the same code to update another table from another from...i get this error:

    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

    I can't figure this one out myself anymore. Hope you experts here could help me again. Many thanks!

    here's my code anyway...(my dataset, connection and dataadapter were created through the wizard)

    Dim dr As DataRow
    Dim strSQL As String
    Dim cbuild As System.Data.OleDb.OleDbCommandBuilder

    cn1.Open()
    dr = DsProd1.Tables("ProductList").NewRow
    dr("ProductID") = txtProdID.Text
    dr("ProductDescription") = txtProdName.Text
    dr("Product Type") = txtProdType.Text
    dr("Dimensions") = txtProdDimen.Text
    dr("Price") = txtProdSRP.Text
    Me.BindingContext(DsProd1, "ProductList").EndCurrentEdit()
    strSQL = "Select * from ProductList"
    daProd1 = New System.Data.OleDb.OleDbDataAdapter(strSQL, cn1)

    cbuild = New System.Data.OleDb.OleDbCommandBuilder(daProd1)

    daProd1.UpdateCommand = cbuild.GetUpdateCommand
    daProd1.Update(DsProd1, "ProductList")
    DsProd1.AcceptChanges()
    daProd1.UpdateCommand.Connection.Close()
    MsgBox("Record has been updated.", MsgBoxStyle.OKOnly)

    End Sub

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Which line is throwing the error ? That wizard just teaches you how to be the worst programmer ever .

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    125
    Really? oh... i'll try to do it in codes instead..

    anyway, it highlights this line when the error appears:

    daProd1.Update(DsProd1, "ProductList")

    is this wrong? but this is the way i see it in other codes...please help! thanks a lot.

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    or just do it this way
    VB Code:
    1. if DsProd1.haschanges then
    2.    dim cb as oledbcommandbuilder
    3.    cb = new oledbcommandbuilder(daProd1)
    4.    daProd1.Update(DsProd1, "ProductList")
    5. end if

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