Home>

11 methods for ASP to connect to the database-This article summarizes the methods for linking various databases using ASP:
1.dsn-less connection method for access database:

set adocon=server.createobject ("adodb.connection")
adoconn.open "driver={microsoft access driver (*. mdb)};dbq =" & _
server.mappath ("path where the database is located")


2.access ole db connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "provider=microsoft.jet.oledb.4.0;"&_
"data source ="&server.mappath ("Path to database")

3.sql server connection method:

set adocon=server.createobject ("adodb.recordset")
adocon.open "driver={sql server};server=(local);uid=***;pwd=***;"&_
"database=database name;
"

4.sql server ole db connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "provider=sqloledb.1;data source=ritant4;"&_
"user id=***;password=***;"&_
"inital catalog=database name"

5.oracle connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "driver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass;"


6.oracle ole db connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "provider=oraoledb.oracle;data source=dbname;user id=admin;password=pass;"

7.dbase connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "driver={microsoft dbase driver (*. dbf)};driverid=277;dbq=------------;"


8.mysql connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "driver={mysql};database=yourdatabase;
uid=username;pwd=yourpassword;option=16386;"


9.visual foxpro connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "driver={microsoft visual foxpro driver};sourcetype=dbc;sourcedb=*. dbc;exclusive=no;"


10.ms text connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "driver={microsoft text driver (*. txt;* .csv)};dbq=-----;"&_
"extensions=asc, csv, tab, txt;persist securityinfo=false;"


11.ms text ole db connection method:

set adocon=server.createobject ("adodb.connection")
adocon.open "provider=microsof.jet.oledb.4.0;data source=your_path;"&_
"extended properties" text;fmt=delimited ""