iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Closed Thread
 
LinkBack (1) Thread Tools
Old August 7th, 2003, 05:51 AM   1 links from elsewhere to this Post. Click to view. #1
Highly Reputable Member
 

Join Date: Jul 2003
Location: Ipswich, UK
Posts: 686
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Smokie will become famous soon enough
Database Connection Strings

ODBC Driver for Access
For Standard Security:

<font color="blue">oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\somepath\mydb.mdb;" & _
"Uid=admin;" & _
"Pwd="</font id="blue">

If you are using a Workgroup (System database):

<font color="blue">oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\somepath\mydb.mdb;" & _
"SystemDB=c:\somepath\mydb.mdw;", _
"myUsername", "myPassword"</font id="blue">

If want to open up the MDB exclusively

<font color="blue">oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\somepath\mydb.mdb;" & _
"Exclusive=1;" & _
"Uid=admin;" & _
"Pwd=" </font id="blue">

If MDB is located on a Network Share

<font color="blue">oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\\myServer\myShare\myPath\myDb.mdb;" & _
"Uid=admin;" & _
"Pwd="</font id="blue">

If MDB is located on a remote machine

- Or use an XML Web Service via SOAP Toolkit or ASP.NET
- Or upgrade to SQL Server and use an IP connection string
- Or use an ADO URL with a remote ASP web page
- Or use a MS Remote or RDS connection string


If you don't know the path to the MDB (using ASP)

<<font color="yellow">%</font id="yellow"> <font color="green">' ASP server-side code</font id="green">
<font color="blue">oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & Server.MapPath(".") & "\myDb.mdb;" & _
"Uid=admin;" & _
"Pwd="</font id="blue">
<font color="yellow">%</font id="yellow">>
This assumes the MDB is in the same directory where the ASP page is running. Also make sure this directory has Write permissions for the user account.


If you don't know the path to the MDB (using VB)

<font color="blue">oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & App.Path & "\myDb.mdb;" & _
"Uid=admin;" & _
"Pwd="</font id="blue">
This assumes the MDB is in the same directory where the application is running.


ODBC Driver for Excel
<font color="blue">oConn.Open "Driver={Microsoft Excel Driver (*.xls)};" & _
"DriverId=790;" & _
"Dbq=c:\somepath\mySpreadsheet.xls;" & _
"DefaultDir=c:\somepath" </font id="blue">



ODBC Driver for Lotus Notes
<font color="blue">oConn.Open "Driver={Lotus NotesSQL 3.01 (32-bit) ODBC DRIVER (*.nsf)};" & _
"Server=myServerName;" & _
"Database=mydir\myDbName.nsf;" & _
"Uid=myUsername;" & _
"Pwd=myPassword" & _</font id="blue">



ODBC Driver for MySQL (via MyODBC)
To connect to a local database

<font color="blue">oConn.Open "Driver={mySQL};" & _
"Server=MyServerName;" & _
"Option=16834;" & _
"Database=mydb"</font id="blue">

To connect to a remote database

<font color="blue">oConn.Open "Driver={mySQL};" & _
"Server=db1.database.com;" & _
"Port=3306;" & _
"Option=131072;" & _
"Stmt=;" & _
"Database=mydb;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">


ODBC Driver for Oracle (from Microsoft)
For the current Oracle ODBC Driver from Microsoft

<font color="blue">oConn.Open "Driver={Microsoft ODBC for Oracle};" & _
"Server=OracleServer.world;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">

For the older Oracle ODBC Driver from Microsoft

<font color="blue">oConn.Open "Driver={Microsoft ODBC Driver for Oracle};" & _
"ConnectString=OracleServer.world;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">



ODBC Driver for Oracle (from Oracle)
<font color="blue">oConn.Open "Driver={Oracle ODBC Driver};" & _
"Dbq=myDBName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">

Where: The DBQ name must be defined in the tnsnames.ora file



ODBC Driver for SQL Server
For Standard Security

<font color="blue">oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">

For Trusted Connection security

<font color="blue">oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Uid=;" & _
"Pwd="</font id="blue">
' Or
<font color="blue">oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Trusted_Connection=yes"</font id="blue">

To Prompt user for username and password

<font color="blue">oConn.Properties("Prompt") = adPromptAlways
oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"DataBase=myDatabaseName"</font id="blue">

To connect to SQL Server running on the same computer

<font color="blue">oConn.Open "Driver={SQL Server};" & _
"Server=(local);" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">

To connect to SQL Server running on a remote computer (via an IP address)

<font color="blue">oConn.Open "Driver={SQL Server};" & _
"Server=xxx.xxx.xxx.xxx;" & _
"Address=xxx.xxx.xxx.xxx,1433;" & _
"Network=DBMSSOCN;" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"</font id="blue">
Where:
- xxx.xxx.xxx.xxx is an IP address
- 1433 is the default port number for SQL Server.
- "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named
Pipes (Q238949)



ODBC Driver for Text
<font color="blue">oConn.Open _
"Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=c:\somepath\;" & _
"Extensions=asc,csv,tab,txt" </font id="blue">
Then specify the filename in the SQL statement:

<font color="blue">oRs.Open "Select * From customer.csv", _
oConn, adOpenStatic, adLockReadOnly, adCmdText</font id="blue">

Note: If you are using a Tab delimited file, then make sure you create a schema.ini file, and include the "Format=TabDelimited" option.

Smokie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
database , connection , strings


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/classic-asp/1400-database-connection-strings.htm
Posted By For Type Date
Open Directory - Computers: Programming: Internet: ASP: FAQs, Help, and Tutorials This thread Refback May 11th, 2007 11:29 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Database Connection Error Message Monie Classic ASP 6 November 2nd, 2007 05:08 AM
[SOLVED] Easiest way to open database connection! Monie Databases 4 November 1st, 2007 04:35 AM
Connection to access database thriftyspider Other Languages 1 August 7th, 2007 04:41 PM
Database connection fogofogo Classic ASP 7 December 5th, 2005 10:25 AM
another database connection question! asp and mysql fogofogo Classic ASP 4 December 2nd, 2005 04:48 AM


Search Engine Optimization by vBSEO 3.2.0 RC8