Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


asp insert statement

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,1906
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> asp insert statement
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 asp insert statement - 1/25/2005 8:21:03 PM   
  carlb007

 

Posts: 7
Score: 0
Joined: 1/20/2005
From:
Status: offline
Hi,
ive used a million insert statements using the ododb connection before but this one has me beat. when i run it i get an 'expected end of statement' error on my SQL line with the error occuring after the 2nd quote marks.
ive stripped almost everything out of the statement now trying to get it to work but it just wont. the code is:
<% sql="insert into events(paragraph1) values('"&head1&"')"%>
error here......................................^

my column and table names are correct. ive defined head1 as head1=word, head1="word", head1=2 and nothing will work. if i remove it as a variable and use straight sql ie values('word') it works fine.
whats going on please help! have i gone blind!?
:(

thanks in advance,
Carl.
 
 
Post #: 1
 
 Re: asp insert statement - 1/27/2005 6:14:54 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
remove the quotes if it's a VAR. b/c this line looks correct, so it must be later in the script.

Post more of this script excerpt, to find out if the error is a little later (sometimes it happens that the error is shown in the first line of the Function, while the actual error is somewhere inside the function)

[8)]

(in reply to carlb007)
 
 
Post #: 2
 
 Re: asp insert statement - 1/30/2005 8:29:51 PM   
  carlb007

 

Posts: 7
Score: 0
Joined: 1/20/2005
From:
Status: offline
sql="insert into events(paragraph1,paragraph2,paragraph3,date,Event)values('"&p1&"','"&p2&"','"&p3&"','"&my_date&"','"&head1&"')"
error---------------------------------------^
(expected end of statement)


------------------------------------------------------------------------------
<% my_date=request.form("startdateday")&"/"&request.form("startdatemonth")&"/"&request.form("startdateyear")%>
<% head=request.form("p1")%>
<% p1=request.form("p1")%>
<% p2=request.form("p2")%>
<% p3=request.form("p3")%>
<% response.write(my_date)%>
<% todo=request.querystring("todo")%>
<% what=request.querystring("what")%>
<% id=request.querystring("id")%>

<% Dim oConn2, oRs2, Ofld2
Set oConn2=Server.CreateObject("ADODB.Connection")
oConn2.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../fpdb/new_db.mdb")
Set oRs2=Server.CreateObject("ADODB.Recordset")
oRs2.open "select * from events order by Date DESC",oConn2 %>

<% if what="event" and todo="create" then%>
<% sql="insert into events(paragraph1,paragraph2,paragraph3,date,Event)values('"&p1&"','"&p2&"','"&p3&"','"&my_date&"','"&head&"')"%>
<% oconn2.execute(sql) %>
item created
<% end if%>

<% if what="event" and todo="del" then%>
<% sql="delete from events where id="&id %>
<% oconn2.execute(sql)%>
item deleted
<% end if%>

<%ors2.Close%>
<%oconn2.close%>
<%Set ors2 = Nothing%>
<%Set oConn2 = Nothing%>

that is ALL of my code :( the lower update statement works fine if i remove the other one out. i have tried inserting all the same variables in the columns with the same error. How can this be when the p1,p2,p3 variables are going through ok and the error is only been hit at the end? there seems to be no logic to this error at all its driving me nuts.
Please help!!

(in reply to carlb007)
 
 
Post #: 3
 
 Re: asp insert statement - 1/30/2005 8:52:10 PM   
  carlb007

 

Posts: 7
Score: 0
Joined: 1/20/2005
From:
Status: offline
also:
<% sql="insert into events(paragraph1,paragraph2,paragraph3,date,event)values('"&p1&"','"&p2&"','"&p3&"','"&my_date&"','test')"%>

<% sql="insert into events(paragraph1,paragraph2,paragraph3,date)values('"&p1&"','"&p2&"','"&p3&"','"&my_date&"')"%>

both the above lines work! so im getting more lost :(
sorry for spamming on post didnt mean to :(

(in reply to carlb007)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> asp insert statement Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts