Web Design and Development Forums

Database Connection Strings

This is a discussion on "Database Connection Strings" within the ASP Forum section. This forum, and the thread "Database Connection Strings are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > ASP Forum

Welcome to Webforumz.com.
Register Now Register now!

Closed Thread
 
LinkBack (1) Thread Tools Rate Thread
Old Aug 7th, 2003, 09:51   1 links from elsewhere to this Post. Click to view. #1 (permalink)
Highly Reputable Member
 
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 755
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.

__________________
Sam

~~~~~ poast.com ~~~~~
²²d(¬_¬)b²²
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

Tags
database, connection, strings

Thread Tools
Rate This Thread
Rate This Thread:

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

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

LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/asp-forum/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 15:29

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Database Connection Error Message Monie ASP Forum 6 Nov 2nd, 2007 08:08
[SOLVED] Easiest way to open database connection! Monie MSSQL & Access 4 Nov 1st, 2007 07:35
Connection to access database thriftyspider Java, JSP, Cold Fusion 1 Aug 7th, 2007 20:41
Database connection fogofogo ASP Forum 7 Dec 5th, 2005 14:25
another database connection question! asp and mysql fogofogo ASP Forum 4 Dec 2nd, 2005 08:48



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 21:13.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
SEO by vBSEO 3.1.0


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59