Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Form Example

Status
Not open for further replies.

Aqif

Programmer
Apr 27, 2002
240
AU
Hi,

I am completely new to ASP and learning parts of it. I just want a simple example by which you create a form on web and submit values to database called DBTest.

Cheers!
Aqif
 
Here is a basic example that might help.

Page1.htm (or asp if there's any prior server side stuff on the page):

<form name=&quot;frmTest&quot; action=&quot;page2.asp&quot; method=&quot;post&quot;>
Input 1:<input type=&quot;text&quot; name=&quot;Input1&quot;>
Input 2:<input type=&quot;text&quot; name=&quot;Input2&quot;>
Input 3:<input type=&quot;text&quot; name=&quot;Input3&quot;><br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>

page2.asp:

<%@ language=&quot;vbscript&quot;%>

<%
Option Explicit

dim dbConn, strSQL

'Establish new DB connection, this example uses MS Jet for Access DB
Set dbConn = server.CreateObject(&quot;ADODB.Connection&quot;)
dbConn.ConnectionString = &quot;Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\yourdatabase.mdb&quot;

'Build the SQL Statement to insert (but could be update)
strSQL = &quot;INSERT INTO yourTableName (Field1, Field2, Field3) VALUES ('&quot; & request.form(&quot;Input1&quot;) & &quot;', '&quot; & request.form(&quot;Input2&quot;) & &quot;', '&quot; & request.form(&quot;Input3&quot;) & &quot;'&quot;

dbConn.Execute (strSQL)

'Could output some HTML here or redirect to another page to show successful process

%>

I haven't tested the above so apologies for any errors/typos but I hope you at least get the idea.

Have a look at for different connection strings.
 
Oh, I forget to put

set dbConn = nothing

at the end...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top