Database connection string MSSQL, Oracle, access

Source: Internet
Author: User
Tags dsn
MSSQL connection string ( 1 ) Oledb
Windows Authentication
" Provider = sqloledb; Data Source = PEK7-6TKX23X \ sqlexpress; initial catalog = test; trusted_connection = yes; " ;
SQL Server Authentication
" Provider = sqloledb; Data Source = 127.0.0.1 \ sqlexpress; initial catalog = test; user id = sa; Password = 123456; " ;
( 2 ) Sqlconnection
Windows Authentication
" Data Source = PEK7-6TKX23X \ sqlexpress; initial catalog = test; trusted_connection = yes; " ;
SQL Server Authentication
" Server = 127.0.0.1 \ sqlexpress; database = test; uid = sa; Password = 123456 " ;
( 3 ) ODBC
Driver = {SQL Server}; server = Server IP address; database = database name; uid = user name; Pwd = password;
( 4 ) DSN Mode
DSN = DSN name; uid = user name; Pwd = password; example: MySQL example
Using System;
Using System. Collections. Generic;
Using System. Data;
Using System. Data. Common;
Using System. LINQ;
Using System. text;
Using System. Data. oledb;
Using System. Data. sqlclient;
Using System. Data. SQL;

NamespaceADO
{
Public ClassConnectiondemo1
{
Public VoidGetoledbtable ()
{
# RegionNamespace
//Using system. Data. oledb;
# Endregion

# RegionOledb access

//Oledb
//C # access method

//Access 2003 provider = Microsoft. Jet. oledb.4.0
//Access 2007 provider = Microsoft. Ace. oledb.12.0

// (1) No Database Password, no user password, open in sharing mode
// "Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb ;"
// (2) There is a database password and no user password. This mode is enabled exclusively.
// "Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb; Jet oledb: Database Password = 123"
// (3) You can use this method if you have a database password. However, even if you have a password, it must be empty. This mode is enabled exclusively.
// "Provider = Microsoft. jet. oledb.4.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb; Jet oledb: Database Password = 12345; persist Security info = true; Password =; user id = admin"

# Endregion

# RegionOledb MSSQL

//Oledb
//C # how to connect to MSSQL

// Windows Authentication
// "Provider = sqloledb; Data Source = PEK7-6TKX23X \ sqlexpress; initial catalog = test; trusted_connection = yes ;";
// SQL Server Authentication
// "Provider = sqloledb; Data Source = 127.0.0.1 \ sqlexpress; initial catalog = test; user id = sa; Password = 123456 ;";

# Endregion

# RegionOledb Oracle
//Oledb
//C # connection to Oracle

//"Provider = msdaora; Data Source = mydatabasealias; user id = myuid; Password = mypassword ";
# Endregion

// String strconn = @ "provider = Microsoft. Ace. oledb.12.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb; Jet oledb: Database Password = 123 "; // Access 2007
String Strconn =
@" Provider = sqloledb; Data Source = 127.0.0.1 \ sqlexpress; initial catalog = test; user id = sa; Password = 123456; " ;
Oledbconnection conn = New Oledbconnection (strconn );
Oledbcommand comm = New Oledbcommand ();

Comm. commandtext = " Select * from users " ;
Comm. commandtype = commandtype. text;
Comm. Connection = conn;
If (Conn. State! = Connectionstate. open)
{
Conn. open ();
Dataset DS = New Dataset ();
Oledbdataadapter da = New Oledbdataadapter (Comm );
Da. Fill (DS );
Conn. Close ();
}
}

Public void getsqlconnectiontable ()
{< br> # region namespace
/// using system. data. sqlclient;
# endregion

# region MSSQL sqlconnection
/// sqlconnection
/// C # method of connecting to MSSQL

// Windows Authentication
// " Data Source = PEK7-6TKX23X \ sqlexpress; initial catalog = test; trusted_connection = yes; ";
/// SQL Server Authentication
// " Server = 127.0.0.1 \ sqlexpress; database = test; uid = sa; password = 123456 ";
# endregion

// String strconn = @ "Server = 127.0.0.1 \ sqlexpress; database = test; uid = sa; Password = 123456 ";
String Strconn = @" Data Source = PEK7-6TKX23X \ sqlexpress; initial catalog = test; trusted_connection = yes; " ;

Sqlconnection conn = New Sqlconnection (strconn );
Sqlcommand comm = New Sqlcommand ();
Comm. commandtext = " Select * from users " ;
Comm. commandtype = commandtype. text;
Comm. Connection = conn;

If (Conn. State! = Connectionstate. open)
{
Conn. open ();
Dataset DS = New Dataset ();
Sqldataadapter da =New Sqldataadapter (Comm );
Da. Fill (DS );
Conn. Close ();
}

}
}
}

 

Oracle connection string oledb
" Provider = msdaora; Data Source = mydatabasealias; user id = myuid; Password = mypassword " ;

 

Access connection string // Oledb
// C # access method

//Access 2003 provider = Microsoft. Jet. oledb.4.0
//Access 2007 provider = Microsoft. Ace. oledb.12.0

// (1) No Database Password, no user password, open in sharing mode
// "Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb ;"
// (2) There is a database password and no user password. This mode is enabled exclusively.
// "Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb; Jet oledb: Database Password = 123"
// (3) You can use this method if you have a database password. However, even if you have a password, it must be empty. This mode is enabled exclusively.
// "Provider = Microsoft. jet. oledb.4.0; Data Source = D: \ qjx document \ genericdemo \ data \ student. accdb; Jet oledb: Database Password = 12345; persist Security info = true; Password =; user id = admin"

MS access ODBC open interface connection string

Standard link:

"Driver = {microsoftaccessdriver (*. mdb)}; DBQ = c: \ app1 \ your database name. mdb; uid = your username; Pwd = your password;"

If no user name or password is set for the Access database, leave it blank. The same below.

Workgroup connection:

"Driver = {Microsoft Access Driver (*. MDB)}; DBQ = c: \ app1 \ your database name. MDB; systemdb = c: \ app1 \ your database name. MDW;"

Dedicated connection:

"Driver = {Microsoft Access Driver (*. MDB)}; DBQ = c: \ app1 \ your database name. MDB; exclusive = 1; uid = your user name; Pwd = your password;"

MS access oledb & oledbconnection (oledb interface under. net) for the link

Common (most commonly used) Access database connection:

"Provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ app1 \ your database name. mdb; user id = admin; Password ="

Use a working group (System Database) to connect to the ACCESS database:

"Provider = Microsoft. jet. oledb.4.0; Data Source = c: \ app1 \ your database name. MDB; Jet oledb: System database = c: \ app1 \ Name of your system database. MDW"

Connect to the ACCESS database with a password:

"Provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ app1 \ your database name. mdb; Jet oledb: Database Password = your password"

Connect to the ACCESS database on the LAN Host:

"Provider = Microsoft. Jet. oledb.4.0; Data Source = \\ SERVER_NAME \ pai_name \ pai_path \ your database name. MDB"

Connect to the ACCESS database on the remote server:

"Provider = MS remote; Remote Server = http: // Remote Server IP; remote provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ app1 \ your database name. MDB"

MS access ODBC open interface connection string

Standard link:

"Driver = {microsoftaccessdriver (*. mdb)}; DBQ = c: \ app1 \ your database name. mdb; uid = your username; Pwd = your password;"

If no user name or password is set for the Access database, leave it blank. The same below.

Workgroup connection:

"Driver = {Microsoft Access Driver (*. MDB)}; DBQ = c: \ app1 \ your database name. MDB; systemdb = c: \ app1 \ your database name. MDW;"

Dedicated connection:

"Driver = {Microsoft Access Driver (*. MDB)}; DBQ = c: \ app1 \ your database name. MDB; exclusive = 1; uid = your user name; Pwd = your password;"

MS access oledb & oledbconnection (oledb interface under. net) for the link

Common (most commonly used) Access database connection:

"Provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ app1 \ your database name. mdb; user id = admin; Password ="

Use a working group (System Database) to connect to the ACCESS database:

"Provider = Microsoft. jet. oledb.4.0; Data Source = c: \ app1 \ your database name. MDB; Jet oledb: System database = c: \ app1 \ Name of your system database. MDW"

Connect to the ACCESS database with a password:

"Provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ app1 \ your database name. mdb; Jet oledb: Database Password = your password"

Connect to the ACCESS database on the LAN Host:

"Provider = Microsoft. Jet. oledb.4.0; Data Source = \\ SERVER_NAME \ pai_name \ pai_path \ your database name. MDB"

Connect to the ACCESS database on the remote server:

"Provider = MS remote; Remote Server = http: // Remote Server IP; remote provider = Microsoft. Jet. oledb.4.0; Data Source = c: \ app1 \ your database name. MDB"

 

___________________________________

Access Method
There are two ways to open access: one is to open access in bytes, and the other is to share access in bytes, other programs can only upload this file, instead of update and delete. if data confidentiality is set, C # cannot be set. it is opened by sharing.

set access secret
there are two types of access secret, which are set in the following way,
( 1 ) " Tools"-> " Security " -> " set the Database Password "
( 2 ) " tool " -> " Security " -> " user and group accounts "
when you manually open an access file, first, the system prompts "login name and password", and then prompts "login data password.

C # using Access
(1) When there is no data confidentiality (there are no methods that can be used to encrypt data), this method is opened in the sharing mode.
Oledbconnection dbconn =NewOledbconnection (@"Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ testdb. mdb;");

(2) When there is data confidentiality (there are no methods that can be used to encrypt data), this method is opened in proportion.
Oledbconnection dbconn =NewOledbconnection (@"Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ testdb. mdb; Jet oledb: Database Password = 12345");

(3) You can use this method when both data confidentiality and data encryption are used. However, even if a password is set for authentication, it must be empty, this method will also be enabled in proportion.
Oledbconnection dbconn =NewOledbconnection (@"Provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ testdb. mdb; Jet oledb: Database Password = 12345; persist Security info = true; Password =; user id = Admin");

At present, we should do this first, and then use it later. Not complete...

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.