Inserting records with into a database with the Command Object

Contributed by
Rating: 2 stars2 stars2 stars2 stars2 stars / 3
October 18, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

<P>Enter your name: <input type="text" size=35 MAXLENGTH=35 name="YourName"></P>
<input type="submit" value="Post Name">
</FORM>
</BODY>

</HTML>
 
 
Page Two (The Process Page)
<HTML>
<HEAD>
<TITLE>Example</title>
</HEAD>
<BODY>
<%

Response.Write Request.Form("YourName") & "<BR>"

Dim cn
Dim cmd
Dim results

' *** These would go into a include file, they are actually the ADO constants that you can't use
' from the asp page

Dim adVarChar
Dim adParamInput
adVarChar = 200
adParamInput = 1

Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "DSN=Example", "sa", ""

set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandText = "INSERT INTO tblUserName Values (?)"
cmd.Parameters.Append cmd.CreateParameter("UserName", 200, 1, 35, Request.Form("YourName"))
cmd.ActiveConnection = cn

cmd.Execute results

Response.Write results & " record written."

%>

</BODY>
</HTML>
blog comments powered by Disqus
DATABASE CODE ARTICLES

- Deployment of the MobiLink Synchronization M...
- MobiLink Synchronization Wizard in SQL Anywh...
- Finding Matching Records in Data Access Pages
- Using the AccessDataSource Control in VS 2005
- A Closer Look at ADO.NET: The Command Object
- A Closer Look at ADO.NET: The Connection Obj...
- Using ADO to Communicate with the Database, ...
- Code Snippets: Counting Records
- Constraints In Microsoft SQL Server 2000
- Multilingual entries into a DB and to be dis...
- Two combos, one textbox example
- ADO Recordset Paging
- SQL Server Database Creator - .NET Version
- Getting A List of Tables From SQL Server
- Discussion & Listserv Module by Mike Eck...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials