473,382 Members | 1,622 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,382 software developers and data experts.

Going nuts...a sql insert statement error...how to debug from here?

Ugh. I'm using the following in an asp.net. I get an Syntax Error in
INSERT INTO Statement on line Cmd1.ExecuteNonQuery().

I've made all my database fields text (just to eliminate that as a
potential problem). I changed all my variables in the insert statement
to text to test as shown below. Still getting the error! I've checked
again and again my db table and field names. Could someone please tell
me where to go from here??? THANKS, Kathy

Dim Conn1 As New OleDbConnection() ' conn string set globally
Dim Adapter As OleDbDataAdapter
Dim Cmd1 As OleDbCommand
Dim strSQL1 As String

strSQL1 = "INSERT INTO tblAnomaly (Date, WorkOrder, Customer, Line,
Station, Assy, SerialNo, User, Item, Type, Problem, ProblemDesc,
Comments, LineStop) VALUES ('08/10/03', '11233', 'XYZ', '07',
'Station1', '865-7446-03BA', '222', 'burkek', 'ToolA not used',
'Problem--Line Stop', 'Material Discrepancy', 'Does not meet spec',
'none', 'true')"

Conn1 = New OleDbConnection(strConn)
Cmd1 = New OleDbCommand(strSQL1, Conn1)
Conn1.Open()
Cmd1.ExecuteNonQuery()
Conn1.Close()
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
6 3227
Without knowing your error message its a bit of a guess.

But I notice that one of your column names is 'Date' this is a reserved word
and may be causing issues.

Steve

"Kathy Burke" <ka**********@attbi.com> wrote in message
news:e6****************@TK2MSFTNGP10.phx.gbl...
Ugh. I'm using the following in an asp.net. I get an Syntax Error in
INSERT INTO Statement on line Cmd1.ExecuteNonQuery().

I've made all my database fields text (just to eliminate that as a
potential problem). I changed all my variables in the insert statement
to text to test as shown below. Still getting the error! I've checked
again and again my db table and field names. Could someone please tell
me where to go from here??? THANKS, Kathy

Dim Conn1 As New OleDbConnection() ' conn string set globally
Dim Adapter As OleDbDataAdapter
Dim Cmd1 As OleDbCommand
Dim strSQL1 As String

strSQL1 = "INSERT INTO tblAnomaly (Date, WorkOrder, Customer, Line,
Station, Assy, SerialNo, User, Item, Type, Problem, ProblemDesc,
Comments, LineStop) VALUES ('08/10/03', '11233', 'XYZ', '07',
'Station1', '865-7446-03BA', '222', 'burkek', 'ToolA not used',
'Problem--Line Stop', 'Material Discrepancy', 'Does not meet spec',
'none', 'true')"

Conn1 = New OleDbConnection(strConn)
Cmd1 = New OleDbCommand(strSQL1, Conn1)
Conn1.Open()
Cmd1.ExecuteNonQuery()
Conn1.Close()
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #2
PJ
query analyzer and similar db clients are your friends. just set a
breakpoint before you execute the query and spit out the sql string. cut
and paste the sql string to your db client and attempt running the query
from there.

"Kathy Burke" <ka**********@attbi.com> wrote in message
news:e6****************@TK2MSFTNGP10.phx.gbl...
Ugh. I'm using the following in an asp.net. I get an Syntax Error in
INSERT INTO Statement on line Cmd1.ExecuteNonQuery().

I've made all my database fields text (just to eliminate that as a
potential problem). I changed all my variables in the insert statement
to text to test as shown below. Still getting the error! I've checked
again and again my db table and field names. Could someone please tell
me where to go from here??? THANKS, Kathy

Dim Conn1 As New OleDbConnection() ' conn string set globally
Dim Adapter As OleDbDataAdapter
Dim Cmd1 As OleDbCommand
Dim strSQL1 As String

strSQL1 = "INSERT INTO tblAnomaly (Date, WorkOrder, Customer, Line,
Station, Assy, SerialNo, User, Item, Type, Problem, ProblemDesc,
Comments, LineStop) VALUES ('08/10/03', '11233', 'XYZ', '07',
'Station1', '865-7446-03BA', '222', 'burkek', 'ToolA not used',
'Problem--Line Stop', 'Material Discrepancy', 'Does not meet spec',
'none', 'true')"

Conn1 = New OleDbConnection(strConn)
Cmd1 = New OleDbCommand(strSQL1, Conn1)
Conn1.Open()
Cmd1.ExecuteNonQuery()
Conn1.Close()
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3
Ugh. Changed the Date field to DateEntered...just to be safe. Then I
copied the string verbatim into an Access query and ran
it...successfully...several times.

The error I get in vb.net is [OleDbException (0x80040e14): Syntax error
in INSERT INTO statement.]

After the string worked directly in an Access query, I copied it back to
the strSQL1 statement and tried again. SAME ERROR EVERY TIME. Where does
one go from here?

Any further suggestions...or workaround? Is there a string length limit
in vb.net for an insert statement that I don't know about?

Thanks again.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
Went back and did an insert by adding each field on...the problem was
the User field name...changed that and works great. It's always the
simple things. I'm going now to memorize all the KEYWORDS!

Thanks again for replying.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5
You can save yourself the trouble of memorizing all the keywords by putting
square brackets around your table and column names. Example:

SELECT [Date] FROM [User]

The square brackets indicate that the value enclosed is a database object,
not a reserved word.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Kathy Burke" <ka**********@attbi.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
Went back and did an insert by adding each field on...the problem was
the User field name...changed that and works great. It's always the
simple things. I'm going now to memorize all the KEYWORDS!

Thanks again for replying.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #6
You can use keywords, by wrapping them in square brackets. E.g. INSERT INTO
tbl_test ([User], [Date]) VALUES ('SomeUser', '13 August 2003'). But, it's
generally not recommended. Usually causes more hassle than it's worth...

Just thought I'd mention it :)

Mun


"Kathy Burke" <ka**********@attbi.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
Went back and did an insert by adding each field on...the problem was
the User field name...changed that and works great. It's always the
simple things. I'm going now to memorize all the KEYWORDS!

Thanks again for replying.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #7

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

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: Bill | last post by:
I'm having what seems to me to be an odd problem. Perhaps there is some explanation, but don't know at this point. Basically I have a form that tracks memberships and donations. The main form...
24
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double...
2
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
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
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...
1
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. ...
11
by: ineedahelp | last post by:
Does anyone see any problems with my INSERT INTO statement? I know that I have done something wrong, but can't figure it out. Basically, I am trying to create a table called LASTGOODDATA and add...
5
by: Shelly | last post by:
This ASPX/SqlServer stuff is driving me nuts. 1 - In a previous post I said I had four tables and all were showing up in Object Explorer (MS SQL Server Management Studio Express), but when I went...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.