Customer Login
.
Webmail Login
.
About Us
.
Contact Us
Windows Rookie Package
Windows Pro Package
Windows Advanced Package
Linux Rookie Package
Linux Pro Package
Linux Advanced Package
Base Dedicated Servers
Business Dedicated Servers
Enterprise Dedicated Servers
Radical Support
How-To Articles
FAQ's
Codebank
Forums
Billing
Save to web space
E-mail Link
Add to Favorites
Simple adding to a database
Added By:
Nickman0
Rated:
(3 of 5) by 8.
Login to rate this snippet.
Language:
Visual Basic Script
Description:
A simple script that adds a person's name into a database.
Code Snippet:
<html> <head> <title>Database Example</title> <meta name="vs_TargetSchema" content="HTML 4.0"> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> </head> <body bgColor="#000000"> <center> <font color="#FFFFFF" size="2" face="Tahoma, Verdana"> <% 'Start with some basic security snippets 'Good idea if your adding personal information like the name of the user although not required Response.Expires = -1000 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "Pragma", "no-cache" Response.AddHeader "cache-control", "private" Dim oConn 'Holds the database connection Dim sql 'Holds the SQL statement Dim DBname 'Holds the database name Dim vName 'Holds the record that we will be inserting into the database vName = "Dude" DBname = Server.MapPath("/username/db/test_db.mdb") 'Dont forget to change your username 'Start our database connection 'But first, lets check to make sure that the user submitted something valid instead of something blank If Len (Name) > 0 Then Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBname & ";" 'Start SQL statement sql = "INSERT INTO People (Name) VALUES ('" & vName & "')" oConn.Execute(sql) 'Tell the user the record was added successfully Response.Write("Thank you " & vName & ", your name was successfully added into the database.") Else 'If the fields didnt make it into the database, tell them Response.Write("You forgot one of the mandatory fields.") End if 'Just make the BACK link here Response.Write("<br><a href=""javascript:history.back(1)"">Back</a>") 'Close the objects DBCon.Close Set DBCon = Nothing %> </font> </body> </html>
FREE Domain Name
,
FREE Website Builder
,
FREE Code Bank
,
FREE Web Hosting
,
24/7 Radical Support
,
90 Day Money Back Guarantee
,
Developer's Forum
,
Web Hosting FAQ
,
Referral Program
,
Joomla Web Hosting
,
Wordpress Web Hosting
,
MediaWiki Web Hosting
,
Zen Cart Web Hosting
,
phpBB Web Hosting
,
Merchant Services
,
Windows 2003 STD Dedicated Server Hosting
,
CentOS Dedicated Server Hosting
,
RedHat Dedicated Server Hosting
,
FreeBSD7 Dedicated Server Hosting
,
Brinkster Datacenter
,
Brinkster Network
,
Firewalls for Dedicated Server Hosting
,
Load Balancing for Dedicated Server Hosting
Home
|
Domains
|
Shared Hosting
|
bMobile
|
Dedicated Hosting
|
Support
|
About Us
|
Webmail
Copyright © 1999-2008
Brinkster Communications Corporation
All Rights Reserved.
Privacy Policy
|
Legal
|
Contact Us
Close X
Live Chat
Support
Live Chat
Billing
Live Chat
Support
Live Chat
Sales.
Click Here
to get support using Skype.
Don't have Skype?
Click here
to download it for FREE!