Current location: Hot Scripts Forums » Programming Languages » ASP » PLEASE HELP! New to programming and getting an error :(


PLEASE HELP! New to programming and getting an error :(

Reply
  #1 (permalink)  
Old 03-24-09, 11:11 AM
MSJRunner MSJRunner is offline
New Member
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
PLEASE HELP! New to programming and getting an error :(

Hi all, I'm brand new to this forum, and I'm trying to do homework for my ASP class. We're using ASP VB script and I'm trying to make the most basic Master/Detail Add/Edit/Delete page. This is the error I am getting...

Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'BID='.

/users/hessel/pub/ASP/Midterm/BooksEditProc.asp, line 15

Here is my code:
Code:
<%
 
set Conn=server.createobject("ADODB.Connection")
connString="Data Source=" & Server.Mappath("Books.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"
Conn.Open connString
 
Dim sql, rs
'Set up connection to the DSN, which will talk to the database
 
sql="select * from Books1 where BID=" & request.form("BID")
set rs=server.createobject("adodb.recordset")
rs.cursortype=3
rs.locktype=3
rs.Open sql, Conn
rs("Name")=request.form("Name")
rs("Author")=request.form("Author")
rs("Publisher")=request.form("Publisher")
rs("YearOfPublication")=request.form("YearOfPublic ation")
rs("Color")=request.form("Color")
rs("Genre")=request.form("Genre") 
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect("booksmaster_2.asp")
%>
Could someone PLEASE help me, I'm sure it's so simple, but I have no idea what's wrong with my code. Thank you so much.

Last edited by digioz; 03-25-09 at 10:23 AM. Reason: Please use code tags.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-24-09, 12:35 PM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,551
Thanks: 2
Thanked 16 Times in 15 Posts
Quote:
Syntax error (missing operator) in query expression 'BID='.
The answer is in the error.

Syntax error (means you didn't write your query properly),
missing operator (what are you trying to compare BID to?, ='' is not valid =NULL is),
in query express 'BID=' (this query is wrong).

Your query needs work.

And you posted in the wrong section.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-25-09, 10:43 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
What's the datatype of the BID field? If it's a string, you have to wrap the data in quotes inside the sql statement
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-03-09, 02:59 PM
webdevelopmenthouse webdevelopmenthouse is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
the query seems perfect to me;

sql="select * from Books1 where BID=" & request.form("BID")

make sure that you are getting the value from submitted form;

check the value of this;

request.form("BID")

you can check its value like this;

response.write(request.form("BID"))
response.end

if it will print nothing, it means you need to check the form you are submitting, there should be a field name there BID and it should have some value to post..

and according to the sql query you wrote.. i am assuming that value of request.form("BID") will be a number.. and in database BID is a numeric field..

kind regards,

Nadir Ali Shah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 09:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.