Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Help with debiging Insert Statement
Old 06-03-2006, 11:17 PM Help with debiging Insert Statement
Skilled Talker

Posts: 79
Trades: 0
Hey to all, anyone know why I am getting this error message.

INSERT INTO tblSearchResults (result, category, location, user) VALUES (( Keyword, CategoryTable, Location, MM_UserName) WHERE result = '%spotted gum%' AND category = '%Door Frames, Jambs & Sills%' AND location = '%Northern Territory%' AND user = '%malhyp%')


Microsoft JET Database Engine
error '80040e14'
Syntax error in INSERT INTO statement. /html/results.asp, line 45

I think I have something the wrong way around...

Component details are...

search.asp page
Form: searchForm (POST)
Text Field: Keyword
Text Field: CategoryTable
Text Field: Location
Session: MM_Username

database properties
Table: tblSearchResults
Number: idSearch (AutoNumber)
Text: result (Which will be inserted by the "Keyword" text field)
Text: category (Which will be inserted by the "CategoryTable" text field)
Text: location (Which will be inserted by the "Location" text field)
Text: user (Which will be inserted by the Session "MM_Username")
malhyp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-04-2006, 08:33 AM Re: Help with debiging Insert Statement
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I don't understand that query at all

MM_Username ?? is that a variable or a column name ???

why have you so many wildcards ??

especially why is the username a wildcard match??
That is the one thing that should be an exact match

looking at it I am thinking that you need to do some serious work on normalising your structures

BUT !!!!! and most importantly !!!!


INSERT queries cannot have a WHERE clause for fairly obvious reasons
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-04-2006, 03:32 PM Re: Help with debiging Insert Statement
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Chris is right. You've got two different queries rolled into one. You'll need to do one of them first (I'd say the search) and then do the insert query after.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 06-05-2006, 06:25 AM Re: Help with debiging Insert Statement
Skilled Talker

Posts: 79
Trades: 0
Ok, it was not a good idea to post that code. It was something that I created using Dreamweaver's SQL creator.

Dose this look better? No wildcards, WHERE statement and MM_UserName is the username session variable that is created.


<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_connSeek_STRING
SQL = "INSERT INTO tblSearchResults (result, category, location, user) " _
& " VALUES('" & Keyword & "', '" & CategoryTable & "', '" & Location & "', '" & MM_UserName & "')"
conn.Execute SQL
%>

Adding this to the code, Response.Write "DEBUG SQL: " & SQL & "<HR>".
Gives me a result of this.
DEBUG SQL: INSERT INTO tblSearchResults (result, category, location, user) VALUES('', '', '', '')
--------------------------------------------------------------------------------
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/html/results.asp, line 34

Any suggestions on how to fix/trouble shoot the error?
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-05-2006, 07:07 AM Re: Help with debiging Insert Statement
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The SQL looks ok

does the Db table allow blank fields?

have you tested it with hardcoded data?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-05-2006, 07:52 AM Re: Help with debiging Insert Statement
Skilled Talker

Posts: 79
Trades: 0
Heya there, I have checked the database, it dose allow blank fields. Im not sure what you mean by testing it with hard coded data.

I was just thinking that I probably had one of the properties in the SQL mixed up.

Are the following comments correct?

----------------------------------------------------------------------------------------------

conn.Open MM_connSeek_STRING (This opens the connection)

SQL = "INSERT INTO tblSearchResults (This inserts the result into the table)

result, category, location, user (This directs the data to the field)

VALUES Keyword CategoryTable Location (These are the names of my text fields in the previouse page)

MM_UserName (This is the username session variable name)

conn.Execute SQL (This executes the whole thing)

-----------------------------------------------------------------------------------------------

Mally
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-05-2006, 08:31 AM Re: Help with debiging Insert Statement
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
not really,

as you can see from the debug print, it is inserting all blank entries (or trying to)

hardcoding means putting actual values in there by setting the variables to some test values
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-05-2006, 09:05 AM Re: Help with debiging Insert Statement
Skilled Talker

Posts: 79
Trades: 0
Will give that a try.
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-05-2006, 09:28 AM Re: Help with debiging Insert Statement
Skilled Talker

Posts: 79
Trades: 0
Heya, I wasnt assigning the variables. As soon as I did it worked.

End resut.

<%
Keyword = request.form("Keyword")
CategoryTable = request.form("CategoryTable")
Location = request.form("Location")
User = Session("MM_UserName")
%>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_connSeek_STRING
SQL = "INSERT INTO tblSearchResults ([result], [category], [location], [user]) " _
& " VALUES('" & Keyword & "', '" & CategoryTable & "', '" & Location & "', '" & User & "')"
conn.Execute SQL
%>
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-05-2006, 09:28 AM Re: Help with debiging Insert Statement
Skilled Talker

Posts: 79
Trades: 0
Thanks again.

Mally
malhyp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with debiging Insert Statement
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30140 seconds with 12 queries