Inserting from a form...

davemcdougdavemcdoug BeginnerLink Clerk
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

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

%>
Sign In or Register to comment.