ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inserting from a form...

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming
View previous topic :: View next topic  
Author Message
davemcdougall



Joined: 17 Jun 2005
Posts: 2

PostPosted: Fri Jun 17, 2005 7:47 pm    Post subject: Inserting from a form... Reply with quote

Hello,

I am a pretty basic ASP user. I am currently trying to build a web app using ASP and MySQl DB. am reading books, surfing the web and reusing other peoples code to get what i want done done...

I have hit a little snag though Smile

I am currently trying to make an insert page and am modeling it off some code a developer at ,my old work wrote. Basically when you action the form it reloads the page and has the insert statement in a select statement at the start of the page. I have figured out how to connect to the DB by installing the MySQL ODBC deriver and writing a connection script. i have figured out how to display the data (mostly using the old code and examples I found and modified onthis website) but the reload isn't working. I think it is because my SQL statement is incorrect oit keeps giving this error -

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement

However when I compare it to other code I don't see what I am missing. I have included my pages code below. If anyone has any comments I would really appreciate it!

Thanks
Dave

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

<html>

<head>

<title>page one</title>

</head>

<body>
<%

Dim sConnection, objConn , objRS

sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=****; UID=****;PASSWORD=****; OPTION=3"

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open(sConnection)


select case Request("Action")
case "Save"
sql = "INSERT INTO fib_merch (fib_merch_nam) VALUES ('" Request("merch _nam") "')"
objConn.Execute sql
end select
%>
<form method="post" action="merch_entry.asp" id=form1 name=form1>
<%saveAction = "Save"%>
Please enter new merchant name: <input type=text name="merch_nam" value="<%=merch_nam%>" maxlength=50 size="50">
<input type=submit name="Action" value="<%=saveAction%>">
</form>

<p>
<B>Existing Merchants</b><br>

<%
Set objRS = objConn.Execute("SELECT fib_merch_id, fib_merch_nam FROM fib_merch")

While Not objRS.EOF
Response.Write objRS.Fields("fib_merch_nam") & "<br>"
objRS.MoveNext
Wend
%>

</p>

</body>

</html>

<%

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

%>
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Mon Jun 27, 2005 9:06 am    Post subject: Reply with quote

You have an error in your VBScript code, this is not an SQL error. Most likely the problem is in the following line:

sql = "INSERT INTO fib_merch (fib_merch_nam) VALUES ('" Request("merch _nam") "')"

Change it to something like:

sql = "INSERT INTO fib_merch (fib_merch_nam) VALUES ('" & Request("merch _nam") & "')"
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial