|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Data base insert Error HELP!"An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" when i do this Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim strSQL As String Dim cmd As OleDbCommand strSQL = "INSERT INTO Engineer(Eng-name,Eng-Qual,Eng-Mobile,Eng-Phone,Eng-NOK,Spec-ID) VALUES([txtName.Text] ,[txtQual.Text], [txtMobile.Text], [txtPhone.Text], [txtNOK.text] ,[Spec-ID.Text] )" cmd = New OleDbCommand(strSQL, OleDbConnection1) OleDbConnection1.Open() cmd.ExecuteNonQuery() End Sub Thanx Bonzol,
Are you sure that there is a primary key in those updates. (The same as with your first question which should work as well) Cor Show quoteHide quote "Bonzol" <Bon***@hotmail.com> schreef in bericht news:1149237919.407176.5850@i40g2000cwc.googlegroups.com... > Can someone tell me why I get this error > > "An unhandled exception of type 'System.Data.OleDb.OleDbException' > occurred in system.data.dll" > > when i do this > > Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnAdd.Click > > > Dim strSQL As String > Dim cmd As OleDbCommand > strSQL = "INSERT INTO > Engineer(Eng-name,Eng-Qual,Eng-Mobile,Eng-Phone,Eng-NOK,Spec-ID) > VALUES([txtName.Text] ,[txtQual.Text], [txtMobile.Text], > [txtPhone.Text], [txtNOK.text] ,[Spec-ID.Text] )" > cmd = New OleDbCommand(strSQL, OleDbConnection1) > OleDbConnection1.Open() > cmd.ExecuteNonQuery() > > > > End Sub > > Thanx > The Primary key is an autogenerated number not to be inputed, via the
form, does that matteR? Bonzol,
You can add this to your code and have than a look what it says. Try cmd.ExecuteNonQuery() Catch ex as OleDBException messagebox.show(ex.Tostring) Cor I am curious what it says, Cor Show quoteHide quote "Bonzol" <Bon***@hotmail.com> schreef in bericht news:1149247043.628118.247760@h76g2000cwa.googlegroups.com... > The Primary key is an autogenerated number not to be inputed, via the > form, does that matteR? > It says
System.Data.oleDB.OleDbException: Syntax error in INSERT INTO statement. at System.data.OleDb.OleDbComman.ExecuteCommandTextErrorHanding(Int32 hr) at System.data.OleDb.OleDbComman.ExecuteCommandTextForSingle Result(tagDBPARAMS dbParams, Object& executeResult) at System.data.OleDb.OleDbComman.ExecuteCommandText(Object& executeResult) at System.data.OleDb.OleDbComman.ExecuteCommand(CommandBehavior, Object& executeResult) at System.data.OleDb.OleDbComman.ExecuteCommandCommandBehaviour behaviour, String method) at System.data.OleDb.OleDbComman.ExecuteCommand.ExecuteNonQuery() at.Project1.frmNewEngineer.btnAdd_click(obkect sender, EventArgs e) in E c:\inetpub/wwwProject1\newEngineer.vb:line 326 Bonzol,
Doi, you did not follow the code from Ghost..... Have a look at that last part about the parameters in his code. Cor
Calling VB.Net classes from VB6
Adding a row to a table help! VB.NET Screen Stops Refreshing After Losing Focus?? Offset lines appearing over form after delay (NVIDIA Chipset) How to measure bandwidth need by the application Why doesn't changing the position in a table change the position of the DatGridView that's bound to UI to enter values into a structure Restart, but after a delay Crypto removing white spaces from byte array Detect Screen Resolution |
|||||||||||||||||||||||