Using Stored Procedures to write records and retrieve ALL DATA

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
September 01, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement
The example shows how to input data from a html page, write the records to a sql server database.  After the record is written all the data is passed back to the asp page and written out

Have an input form Example below show's some sample data being inputted.
 

Here is the results that are written out.


Code for Asp Page

'Declares all local variables
dim conn
dim rs
dim strsql
dim strsql2
dim strsql3

'First part of formatted string
strsql = "DECLARE " & CHR(10) & "@Id_Req " & "INT" & CHR(10)
'Second part of Formatted string-all values from form
strsql2 ="exec " & "sp_EmpInfo" & " '" & request("txtFirstName") & "'," & "'" & request("txtLastName") & "', " & "'" & request("txtaddress") & "', " & "'" & request("txtcity") & "', "& "@Id_Req " & "OUTPUT" & chr(10)
Third part of formatted string
strsql3 ="SELECT * FROM AllData WHERE RecordId = @Id_Req" & Chr(10)
'Putting all the values together
strsql = strsql & strsql2 & strsql3
response.write "<b>" & "Sql Statement that is passed to the database" & "</b>" & "<br>" & "<br>"
response.write strsql

'Create connection object & open it
set conn = server.createobject("adodb.connection")
conn.open "example"
'Create recordset object & place string that is executed
'so values can be stored and written out

set rs = server.createobject("adodb.recordset")
rs = conn.execute(strsql) %>
<html>
<head>
<title>Results Page</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>
<body>

<p><strong>Record Id # and all information entered on <br>
previous page.</strong></p>

<table border="1" width="50%">
<tr>
<td width="50%">ID Number: </td>
<td width="50%">&nbsp;<% = rs("recordid") %></td>
</tr>
<tr>
<td width="50%">Date submitted:</td>
<td width="50%">&nbsp;<% = date() %></td>
</tr>
<tr>
<td width="50%">First Name: </td>
<td width="50%">&nbsp;<% = rs("fname") %></td>
</tr>
<tr>
<td width="50%">Last Name:</td>
<td width="50%">&nbsp;<% = rs("lname") %></td>
</tr>
<tr>
<td width="50%">Address: </td>
<td width="50%">&nbsp;<% = rs("address") %></td>
</tr>
<tr>
<td width="50%">City:</td>
<td width="50%">&nbsp;<% = rs("City") %></td>
</tr>
</table>
<% set rs = nothing %>
</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 2 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials