|
-
Dec 31st, 2005, 05:01 AM
#1
Thread Starter
New Member
ADD + DELETE error
hi i tried to add and delete a record but i always get an error in my Dataadapter it's something like error in system....dll.
here is the code i typed
if anyone could help thanks in advance
the sqlcommand is
sqlcommand.commandtext="Select * from Hardware"
VB Code:
intteller = 0
If intteller <> -1 Then
Dim nieuweRij As DataRow
Dim mijntabel As New DataTable
mijntabel = beheerdersDataset.Tables(0)
nieuweRij = beheerdersDataset.Tables(0).NewRow()
nieuweRij.Item("Nr") = txtnr.Text
nieuweRij.Item("Voornaam") = txtvoornaam.Text
nieuweRij.Item("Achternaam") = txtachternaam.Text
nieuweRij.Item("E-mail") = txtemail.Text
nieuweRij.Item("GSM") = txtgsm.Text
beheerdersDataset.Tables(0).Rows.Add(nieuweRij)
' ' here is get my error in the next line
mijnAdapter.Update(beheerdersDataset)
MsgBox("New Record added to the Database")
End If
'delete
hardwareDataset.Tables(0).Rows(intteller).Delete()
aantalrec = aantalrec - 1
intteller = 0
Navigatierecords()
' here is get my error in the next line
mijnAdapter.Update(hardwareDataset)
-
Dec 31st, 2005, 05:56 AM
#2
Re: ADD + DELETE error
Where are your update commands? If you did not specify any, then you need to set a commandbuilder to autogenerate the insert/update/delete commands when you call Update on your dataadapter... you can do it with a simple line of code...
VB Code:
'put this line of code (modifying it for your object names) after you create your adapter
Dim MyCmdBuilder As New System.Data.OleDb.OleDbCommandBuilder(MyAdapter)
Of course, if you arent using an oledb dataadapter, be sure to change it to the type of adapter you are using...
-
Dec 31st, 2005, 06:29 AM
#3
Thread Starter
New Member
Re: ADD + DELETE error
should i write mycmdbuilder.update(mydataset)
-
Dec 31st, 2005, 06:33 AM
#4
Re: ADD + DELETE error
no you just call your update just like you were doing before... unless you already tried that (which I think you have done)... so if theres still an error, we need the exact error message... put a try/catch block around the update command, and display the error message...
-
Dec 31st, 2005, 08:34 AM
#5
Thread Starter
New Member
Re: ADD + DELETE error
i tried it your way but i get the error
http://www.homeandlearn.co.uk/NET/im...ctionError.jpg
this is the error i get
Last edited by makaveli19; Dec 31st, 2005 at 09:36 AM.
-
Dec 31st, 2005, 03:58 PM
#6
Re: ADD + DELETE error
have you put try/catch blocks to try to catch the exact error message? Look below for how to do it. Are you using an oledbdataadapter? or a different data adapter? If you are using a SQL data adapter, you have to change it to "System.Data.SqlClient.SqlCommandBuilder"
VB Code:
Try
'some code you wish to catch exceptions on...
Catch ex as System.Exception
Msgbox ex.message
End Try
Last edited by gigemboy; Dec 31st, 2005 at 04:01 PM.
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
|