DSN-Less Connection Code Generator by David Lohmann

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 2
August 13, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

It's a simple form which writes out my DSN-less connection code for me. Just type in the variable names and hit submit, then copy and paste. Used mainly for adding or updating records without using the ADODB.Connection object.

Thanks
David Lohmann

 

<%@language=vbscript%>
<!--****Use this code freely. Just remember me when you're recruiting!!!****
//****Dave Lohmann dloh@uk2.net****-->

<%

dim sent, dbcon, folder, file, rsname, table, csr1, csr2

sent=request.form("sent")
if sent="true" then
dbcon=request.form("T1")
folder=request.form("T2")
file=request.form("T3")
table=request.form("T4")
rsname=request.form("T5")
csr1=request.form("T6")
csr2=request.form("T7")

response.write "<b>Copy and paste this code into your ASP page.</b><p>"
response.write dbcon&" = ""DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=""&Server.mapPath("&""""
response.write folder&"\"&file&".mdb"")<p>"

response.write "Set "&rsname&"=Server.CreateObject("&"""ADODB.Recordset"&""")<p>"
response.write rsname&".Open "&""""&table&""", "&dbcon&", "&csr1&", "&csr2&"<p>"
response.write "<b>(Don't forget to close the Recordset object.)</b><p>"
response.write rsname&".close<p>Set "&rsname&"=Nothing"
Else

%>

<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">

<title>DSN-Less Connection Code Generator</title>
</head>

<body bgcolor="#FFFFFF">

<h1 align="center">DSN-Less Connection Code Generator</h1>
<h4 align="center">(For Microsoft Access)</h4>
<hr>
<form action="setconn.asp" method="POST">
<div align="center"><table border="0"
cellpadding="4" cellspacing="0" width="100%">
<tr>
<td align="right" width="50%">Database Connection Variable:</td>
<td width="50%"><input type="text" size="20"
name="T1" value="strConn"></td>
</tr>
<tr>
<td align="right" width="50%">Database Folder:</td>
<td width="50%"><input type="text" size="20"
name="T2"></td>
</tr>
<tr>
<td align="right" width="50%">Database Filename:</td>
<td width="50%"><input type="text" size="20"
name="T3">.mdb</td>
</tr>
<tr>
<td align="right" width="50%">Database Table Name:</td>
<td width="50%"><input type="text" size="20"
name="T4"></td>
</tr>
<tr>
<td align="right" width="50%">Recordset Variable Name:</td>
<td width="50%"><input type="text" size="20"
name="T5" value="ObjRs"></td>
</tr>
<tr>
<td align="right" width="50%">Cursor Type 1:</td>
<td width="50%"><input type="text" size="20"
name="T6" value="2"></td>
</tr>
<tr>
<td align="right" width="50%">Cursor Type 2:</td>
<td width="50%"><input type="text" size="20"
name="T7" value="2">
<input type="hidden" name="sent" value="true"></td>
</tr>
</table>
<p align="center"><input type="submit"
name="B1" value="Submit">&nbsp;<input type="reset" name="B2"
value="Reset"></p>
</div>
</form>
</body>
</html>
<%End If%>

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

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