Web Templates
Web Templates  
Photoshop Layouts  
Flash Templates  
Templates Resource - Web Templates
   
 
  Sign UpPassword
Templates Resource Services Support Specials Members View Cart
 
  Photoshop Tutorials
  HTML Tutorials
  ASP Tutorials
  CSS Tutorials
  Javascript Tutorials
  PHP Tutorials
  XML Tutorials
  Flash Tutorials
  Fireworks Tutorials
  3D Studio Max Tutorials
  Cinema 4d Tutorials
  Graphics
  Website Tools
  Web Templates
  About Templates Resource
  Affiliates Program
  TR Support
  Webmaster Resources
 Columbia Tech Support

WebDesignHelper.co.uk


 

Tutorials: ASP - Active Server Pages

Database Insert

Beginner

 

Inserting Rows into a Database
This tutorial will show you how to insert a row of data into a database using ASP and an MS Access database. You can do it on one ASP file, but we'll have two files: one processor page (proc.asp), and one form page (form.asp). Then, we'll make the MS Access database that corresponds to the ASP.

PART I - CREATING THE PROCESSING PAGE: proc.asp
This page will catch the form data, open a connection with the Access database (change "test.mdb" to your database), insert the row using a sql query, and close the connection. If it executes fine, it will print out "done inserting row".
Here's the code:

<%
Dim Conn
Dim SqlTemp

If request("insrow") = "1" THEN
psubject = request("pSubj")
pdate = request("pDate")
ptext = request("pText")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\test.mdb")& ";"
Conn.Open

SQLTemp = "INSERT INTO tblTest (pSubj, pDate, pText) VALUES ('" & psubject & "', " & pdate & ", '" & ptext & "')"
Conn.execute(SQLTemp)

Conn.Close
Set Conn = Nothing
response.write("<p>done inserting row</p>")
End If

%>


PART II - CREATING THE FORM: form.asp
Here's a simple form that will use the "post" method to submit the info to the proc.asp page:

 

<form name="frmInsert" method="post" action="test.asp">
<input type="hidden" name="insrow" value="1">
Subject: <input type="text" name="pSubj" size="13"><br>
Date: <input type="text" name="pDate" size="13"><br>
Text: <input type="text" name="pText" size="13"><br>
<input type="submit" size=8 value="Submit">
</form>


PART III - CREATING THE DATABASE: test.mdb
Make a table in the database called "tblTest" (you may change it, but make sure it corresponds with the above table name). Inside the database, make an Autonumber row called "pSubj" which is the Primary Key, a date row called "pDate", and a row called "pText" with the memo row-type.
And there you have it, a database, a form, and a processor ready for data entry!

NOTE: Had trouble connecting to the database? Click here.

 

This tutorial is provided to you by Spoono

More Tutorials
 

Active Server Pages Tutorials

AIM Screennames Viewer
This tutorial will show you how to make a script to see who has seen your AOL Instant Messenger profile.

Intermediate

Alternating Row Colors
Learn the basics of creating wonderfully abstract objects.

Intermediate

Browser Redirect
Learn how to do a Browser Redirect using the power of ASP.

Beginner

Cookies
Learn how to use cookies in ASP.

Intermediate

Counter
Learn how to make a hit counter in ASP.

Beginner

Database Connection
Learn the different ways to connect to different databases.

Intermediate

Database Insert
Learn how to insert a row into a MS Access database.

Beginner

Displaying Database
Learn a quick and easy way to display information from a database.

Beginner

Form Mail via CDONTS
Learn how to send mail using ASP and CDONTS

Intermediate

Form Mail via CDOSYS
Learn how to send mail using ASP and CDOSYS.

Intermediate

Number of Users Online
Use this code to display the number of users browsing.

Intermediate

Requests
Learn how to make use of requests.

Beginner

Sessions
Learn an alternative and effective solution to cookies in ASP using sessions.

Intermediate

String Functions
Learn the basic string functions available in ASP using VBScript

Beginner

XML Parsing
Use this nifty script to parse XML into HTML

Intermediate

Get help using .ASP here!

Get Free ASP Scripts here!

More Tutorials

Featured Web Templates

Web Template Preview 92313701

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313801

User Level:

Intermediate

Category:

Flash



Web Template Preview 92314001

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313901

User Level:

Intermediate

Category:

Flash


Web Template Preview 92314101

User Level:

Intermediate

Category:

Flash


Web Template Preview 92314201

User Level:

Intermediate

Category:

Flash


Web Template Preview 92314301

User Level:

Intermediate

Category:

Flash


Web Template Preview 92314401

User Level:

Intermediate

Category:

Flash


Web Template Preview 92314501

User Level:

Intermediate

Category:

Flash



Web Template Preview 92314601

User Level:

Intermediate

Category:

Flash

 

 

 

Templates Resource FAQ Services Terms of Use Site Map Support View Cart

© Copyright 2003-2008 Templates Resource