473,486 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax error in INSERT INTO statement. Pls Help

21 New Member
Hi ,

I had written a code in C# as below :

Expand|Select|Wrap|Line Numbers
  1. string insertString = "INSERT INTO Module_Repair_Info (FailureNo, XmtrType, SerialNo, Hardware Rev, Software Rev, Firmware Rev) VALUES (' ', '" + Model + "', '" + ModuleSerialNumber + "', '" + Hardware + "', '" + Software + "', '" + Firmware + "')";
When the programs reaches this step :

Expand|Select|Wrap|Line Numbers
  1. OleDbCommand myCommand = new OleDbCommand(insertString, myConn2);
  2. myCommand.ExecuteNonQuery();
it shows Syntax error in INSERT INTO statement. I am inserting values from Table A into Table B.

I have no idea wat went wrong here. Pls help thanks!
Mar 8 '07 #1
5 900
avkdsiva
23 New Member
what do you want to insert into the first field, FailureNo??
You are trying to insert ' '

IS it an empty string that you are trying to insert?
IF so, use " " instead of ' '

thanx
Mar 8 '07 #2
radcaesar
759 Recognized Expert Contributor
Insert a line MessageBox.Show (insertString);
Below the insrt command string, it will show you the error.

:)
Mar 8 '07 #3
wertqt
21 New Member
Hi there,
Thanks for all the replies! i solved the problem =P

Cheers!
Mar 9 '07 #4
AricC
1,892 Recognized Expert Top Contributor
Hi there,
Thanks for all the replies! i solved the problem =P

Cheers!
What was the solution?
Mar 9 '07 #5
wertqt
21 New Member
hi AricC ,
i put a sqaure bracket for fields with space between them. For e.g., Hardware Rev, i insert the sq bracket to become [Hardware Rev].
Also, FailureNo is a required field in my database so instead of putting single quote ' ', i insert a space in it to become ' '.

Cheers!
Mar 12 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2188
by: Gérard Leclercq | last post by:
ACCESS First fields are TEXT, last 2 are Numbers The name of the fields are correct. Dim MyConn Set MyConn=Server.CreateObject("ADODB.Connection") MyConn.Open...
7
6644
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
2
1584
by: eric dugal | last post by:
Hi all!! I need your help.... i'm working since 2 hours on a simple insert statement, but couldn't handle it. Here is my code : public int ExecQuery(string SqlString) {
3
2803
by: Neil Zanella | last post by:
Hello, I am trying to execute ADO.NET INSERT statement where one of the fields is coming from a password HTML control. When I access the text with password.Value and print with Response.Write...
3
2482
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
5
2117
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
1
5385
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
2
2795
by: RSH | last post by:
I have a rather simple script that transfers data from a SQL server database to an Access database. The procedure is intended to be dynamic so I am basically adding a datarow and then passing the...
6
5985
by: ewpatton | last post by:
Good day, I've been trying to work with SQL and an Access database in order to handle custom user profiles. I haven't had any trouble reading from my database, but inserting new entries into...
3
1359
by: BreckCogdill | last post by:
Hello, I'm trying to modify some code in simple Forum script - adding an ID field to an insert statement. I have added the field to the d/b & now I'm trying to add this new field to the existing...
0
7105
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
6967
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
7132
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
7180
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...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.