|
-
Jul 20th, 2004, 08:53 PM
#1
Thread Starter
Lively Member
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
-
Jul 20th, 2004, 11:05 PM
#2
Sleep mode
Which line is throwing the error ? That wizard just teaches you how to be the worst programmer ever .
-
Jul 21st, 2004, 12:05 AM
#3
Thread Starter
Lively Member
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.
-
Jul 21st, 2004, 12:10 AM
#4
or just do it this way
VB Code:
if DsProd1.haschanges then
dim cb as oledbcommandbuilder
cb = new oledbcommandbuilder(daProd1)
daProd1.Update(DsProd1, "ProductList")
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|