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"> <input type="reset" name="B2" value="Reset"></p> </div> </form> </body> </html> <%End If%> |