473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data base insert Error HELP!

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

Jun 2 '06 #1
6 1169
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

"Bonzol" <Bo****@hotmail.com> schreef in bericht
news:11********************@i40g2000cwc.googlegrou ps.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

Jun 2 '06 #2
The Primary key is an autogenerated number not to be inputed, via the
form, does that matteR?

Jun 2 '06 #3
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

"Bonzol" <Bo****@hotmail.com> schreef in bericht
news:11**********************@h76g2000cwa.googlegr oups.com...
The Primary key is an autogenerated number not to be inputed, via the
form, does that matteR?

Jun 2 '06 #4
It says

System.Data.oleDB.OleDbException: Syntax error in INSERT INTO
statement.
at System.data.OleDb.OleDbComman.ExecuteCommandTextEr rorHanding(Int32
hr)
at System.data.OleDb.OleDbComman.ExecuteCommandTextFo rSingle
Result(tagDBPARAMS dbParams, Object& executeResult)
at System.data.OleDb.OleDbComman.ExecuteCommandText(O bject&
executeResult)
at System.data.OleDb.OleDbComman.ExecuteCommand(Comma ndBehavior,
Object& executeResult)
at System.data.OleDb.OleDbComman.ExecuteCommandComman dBehaviour
behaviour, String method)
at System.data.OleDb.OleDbComman.ExecuteCommand.Execu teNonQuery()
at.Project1.frmNewEngineer.btnAdd_click(obkect sender, EventArgs e) in
E c:\inetpub/wwwProject1\newEngineer.vb:line 326

Jun 2 '06 #5
Bonzol,

Doi, you did not follow the code from Ghost.....

Have a look at that last part about the parameters in his code.

Cor
Jun 2 '06 #6
yeah, I had a problem with it, and am waiting a reply in that other
thread

Jun 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
12
by: joaotsetsemoita | last post by:
Hello everyone, im completly new to vb.net and I was assigned to do a simple piece of software that just had to select from um db in a MS access data base and insert into a SQL server Database....
8
by: slb813 | last post by:
Hello, I am having a problem that I can't seem to work out. I am running Apache 2.2 on a Windows XP platform, using PHP5. I am attempting to insert a row into a MS Access data base with a PHP...
14
by: rashmidutt | last post by:
hello sir i am making project on vb.net language..and project is on hospital management..its major project..and too many fields are present in its data base..i was connecting data base in forms but...
8
by: Betikci Boris | last post by:
Can not insert data into SQLite3 database through browser however i can easily insert data into my db from konsole, in both attmpts i used php 5.2.6 on 2.6.25.* linux kernel i think there is a...
2
by: DUMAS64 | last post by:
my data ase has five field need enter new data(record) after the last input when I press enter for the program to insert the five details I receive the following error and I cannot figure where I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.