473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,387 developers and data experts.

Connection strings

sashi
1,754 Expert 1GB
MsAccess - Connection String

Standard security
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  2.            "Data Source=c:\somepath\myDb.mdb;" 
  3.  
If using a Workgroup (System Database)
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  2.            "Data Source=c:\somepath\mydb.mdb;" & _ 
  3.            "Jet OLEDB:System Database=MySystem.mdw", _
  4.            "myUsername", "myPassword" 
  5.  
If MDB has a database password
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  2.            "Data Source=c:\somepath\mydb.mdb;" & _ 
  3.            "Jet OLEDB:Database Password=MyDbPassword", _
  4.            "myUsername", "myPassword"
  5.  
If want to open up the MDB exclusively
Expand|Select|Wrap|Line Numbers
  1. oConn.Mode = adModeShareExclusive
  2. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  3.            "Data Source=c:\somepath\myDb.mdb;"  
  4.  
If MDB is located on a network share
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  2.            "Data Source=\\myServer\myShare\myPath\myDb.mdb"
  3.  
ODBC - Open Database Connectivity

DSN
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "DSN=mySystemDSN;" & _ 
  2.            "Uid=myUsername;" & _ 
  3.            "Pwd=myPassword"
  4.  
File DSN
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _ 
  2.            "Uid=myUsername;" & _
  3.            "Pwd=myPassword"
  4.  
MsSQL Server - Connection String

For Standard Security
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=sqloledb;" & _ 
  2.            "Data Source=myServerName;" & _
  3.            "Initial Catalog=myDatabaseName;" & _
  4.            "User Id=myUsername;" & _
  5.            "Password=myPassword"
  6.  
OR

Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=sqloledb;" & _ 
  2.            "Server=myServerName;" & _
  3.            "Database=myDatabaseName;" & _
  4.            "User Id=myUsername;" & _
  5.            "Password=myPassword"
  6.  
For a Trusted Connection
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=sqloledb;" & _
  2.            "Data Source=myServerName;" & _
  3.            "Initial Catalog=myDatabaseName;" & _
  4.            "Integrated Security=SSPI"
  5.  
To connect to a "Named Instance"
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=sqloledb;" & _
  2.            "Data Source=myServerName\myInstanceName;" & _
  3.            "Initial Catalog=myDatabaseName;" & _
  4.            "User Id=myUsername;" & _
  5.            "Password=myPassword"
  6.  
Note: In order to connect to a SQL Server 2000 "named instance", you must have MDAC 2.6 (or greater) installed.

To Prompt user for username and password
Expand|Select|Wrap|Line Numbers
  1. oConn.Provider = "sqloledb"
  2. oConn.Properties("Prompt") = adPromptAlways
  3. oConn.Open "Data Source=myServerName;" & _
  4.            "Initial Catalog=myDatabaseName" 
  5.  
To connect to SQL Server running on the same computer
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=sqloledb;" & _
  2.            "Data Source=(local);" & _
  3.            "Initial Catalog=myDatabaseName;" & _
  4.            "User ID=myUsername;" & _
  5.            "Password=myPassword"
  6.  
To connect to SQL Server running on a remote computer (via an IP address)
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=sqloledb;" & _
  2.            "Network Library=DBMSSOCN;" & _
  3.            "Data Source=xxx.xxx.xxx.xxx,1433;" & _
  4.            "Initial Catalog=myDatabaseName;" & _
  5.            "User ID=myUsername;" & _
  6.            "Password=myPassword"
  7.  
Dec 2 '06 #1
0 12476

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
4
by: Matthew Wells | last post by:
FIRST OF ALL, I APPRECIATE PEOPLE SENDIUNG ME LINKS TO WEB SITES FOR CONNECTION STRINGS BUT AS I'VE SAID BEFORE THAT IS NOT WHAT I NEED. I CAN EASILY OPEN AN ADO CONNECTION OBJECT TO AS400. I...
1
by: stewart | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the...
7
by: Gary Brizard | last post by:
OK. For an n-tier architecture, where is the best place to store the connection string for the DA layer? I don't want to use the reg. Can't use a app.config for a dll. For other projects I...
14
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review,...
4
by: Matt Colegrove | last post by:
I'm working on a web app that is published to a hosting service. I'm developing it on my local PC with VS 2005 and SQL Express. The hosting service DB is SQL Server 2000. I have two...
5
by: Matt | last post by:
Hello, What is the best way to handle the database connection string for a class library project that will be compiled and used as a .dll? This .dll will be accessed via classic ASP and in...
3
by: Harry Strybos | last post by:
Hi All I have a really strange problem occurring in my application. When I read in the application settings for connection strings the following happens: Here are my connection string settings...
9
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.