473,387 Members | 3,684 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.

INSERT INFO statement problem on ASP page

I am attempting to execute an INSERT statement on my page but continually get the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '<'.

/int_code04/myNMLC/insertNewTrackRecord.asp, line 97

I've tested the INSERT stmt both within SQL Server and as a string literal within the page's code with hardcoded values to ensure that the statement works, which is does. But when I assign this statement to a variable using the variables containing the values and then execute it (as shown below), it doesn't work:

"mySQL="INSERT INTO nsn_shipment_tracking_lines (fk_nsn_shipment_tracker, qty_shipped, date_shipped, date_received, tracking_number, shipping_company, date_entered) VALUES (" & fk_ID & ", " & qty_shipped & ", " & shipped_dt_and_clause & ", " & received_dt_and_clause & ", '" & tracking_number & "'," & shipping_company & ", getdate())"

cn.Execute(mySQL)"


When I Response.write the contents of my variable containing the above SQL statement (response.write (mySQL)), I get the following:

INSERT INTO nsn_shipment_tracking_lines (fk_nsn_shipment_tracker, qty_shipped, date_shipped, date_received, tracking_number, shipping_company, date_entered) VALUES (890
, 450, '10/30/2009', '11/8/2009', 'DFTG4385DRE673', 1, getdate())


This looks right to me but again, this doesn’t work. One other “process of elimination” thing I tried was to first remove all of the date field values from the INSERT statement, to see if I could accomplish an insert with out these values (since most fields in the table allow for NULL values). The result was this didn’t make a difference. Then I tried the insert one field at a time; this also made no difference.

Any insight to this troubling issue would be greatly appreciated! Thanks in advance!
Jan 4 '10 #1
1 2482
jhardman
3,406 Expert 2GB
Thanks for doing the basics, I always ask people in your position to response.write the query.

There is definitely something else going on. somehow a less than sign (<) is being sent in the query. If you want, you could post more of the code to let us see, because the query you are posting here isn't being sent.

I generally use a different method: I use a "select" query to populate a recordset, add a new row to the recordset, set the values of that row, then use the recordset's "update" method to update the db. If you want to try that method, the code looks something like this:
Expand|Select|Wrap|Line Numbers
  1. dim query, objConn, objRS
  2. set objConn = server.createobject(adodb.connection)
  3. objConn.open connectionString 'use whatever connection string you want
  4.  
  5. query = "SELECT fk_nsn_shipment_tracker, qty_shipped, date_shipped, date_received, tracking_number, shipping_company, date_entered FROM nsn_shipment_tracking_lines"
  6.  
  7. set objRS = server.createobject(adodb.recordset)
  8. objRS.open query, objConn, adopendynamic, adlockoptimistic
  9. 'adopendynamic and adlockoptimistic are integer constants, 2 and 3 I believe, you can look those up
  10.  
  11. objRS.addnew()
  12. objRS("fk_nsn_shipment_tracker") = fk_id
  13. 'etc
  14. objRS.update()
One of the things I really like about this method, is you can automatically check for duplicate entries by adding a "where" clause to your query, something like "WHERE fk_nsn_shipment_tracker = 165" then before I add a new row, I check if there were any rows returned; if yes, I can say "This record appears to be a duplicate", otherwise I add it. Does this make sense?

Jared
Jan 6 '10 #2

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

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
3
by: A Lonely Programmer | last post by:
Ok i know that using an access db is a corporate nono but i am not about to buy sql for anybody (well maybe myself someday) and an approved msde update must come AFTER i get certain things up and...
0
by: Tim::.. | last post by:
Can someone please help! I'm trying to write an insert statement for a complex datagrid! The database consists of the following data structure! ..tblContent PageID PK ModDate Description...
3
by: | last post by:
I'm picking up an 'IMPORTS' error for a simple database insert based on two input entry boxes in my form? It says an 'Imports' statement must preceede any declarations....... is this perahps the...
7
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
1
by: Ed Dror | last post by:
Hi there, I have ASP <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Guestbook.aspx.vb" Inherits="Guestbook" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
17
by: joberman | last post by:
I've about give up with the whole mysql_insert_id function. Always returns a "0". I do have an auto-incrementing field in my database called "ordernumber", which when I query it from another page,...
2
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT...
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...
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
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.