Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DSN-less connection

Status
Not open for further replies.

mkphan

IS-IT--Management
Jan 9, 2001
18
US
Hi I'm a newbie at this, so could someone give me an idea or step-by-step instructions? Thanks in advance

Here's the case:

I have a MS Access 2000 database and creating some ASP pages to acess the database. I need to create an DSN-less connection to the database using JavaScript (since I don't want to use VBScript).

Secondly, I need to create a recordset to insert data from a form into the database.

Thanks again,

Valerie
 
Hi,

Here is an example from the help pages of IIS5 (you should have this on your machine at ). If you take the time to go thru the help for IIS, you would find a lot more info on ASP and database access.
Code:
<%
var oConn; 
var oRs; 
var filePath;
// Map authors database to physical path
filePath = Server.MapPath(&quot;authors.mdb&quot;);
// Create ADO Connection Component to connect with
// sample database
//You can use Microsoft Data Link from NT5 to create OLE-DB connection string 
oConn = Server.CreateObject(&quot;ADODB.Connection&quot;);
oConn.Open(&quot;Provider=Microsoft.Jet.OLEDB.3.51;Data Source=&quot; +filePath);
// Execute a SQL query and store the results within
// recordset
oRs = oConn.Execute(&quot;SELECT * From authors&quot;);
...
oRs.close();
oConn.close();
%>

As for inserting data from a form, you don't need a recordset. Here again is an example from IIS' help:
Code:
<%
var oConn; 
var oRs; 
var filePath; 
// Map authors database to physical path
filePath = Server.MapPath(&quot;authors.mdb&quot;);
// Create ADO Connection Component to connect
// with sample database
//You can use Microsoft Data Link from NT5 to create OLE-DB connection string 
oConn = Server.CreateObject(&quot;ADODB.Connection&quot;);
oConn.Open(&quot;Provider=Microsoft.Jet.OLEDB.3.51;Data Source=&quot; +filePath);
// to add and delete recordset, it is recommended to use 
//direct SQL statement instead of ADO methods.
oConn.Execute (&quot;insert into authors (author, YearBorn) values ('Paul enfield', 1967)&quot;);
// Delete inserted record
oConn.Execute ( &quot; Delete from Authors where author='paul enfield' and YearBorn = 1967&quot; );
oConn.close();
%>

Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top