Asp.net connection string

Source: Internet
Author: User

I,Use the SQL Sever. NET database provider to connect to SQL Server

<! -- Integrated Security = true indicates that Windows Authentication mode is used -->
<Add key = "connectionstring2" value = "Data Source = LENOVO-THINK; initial catalog = UDS; Integrated Security = true"/>

 

<! -- The first example is a very basic connection string that can be used to establish a connection to sqlserver on the same machine running the code -->
<Add key = "connectionstring1" value = "Server = (local); database = UDS; user id = sa; Pwd =;"/>

<! -- The second example shows a connection string that can be used to connect to the remote server LENOVO-THINK that uses SQL Server Authentication. In fact, this example is still connected to the local machine -->
<Add key = "connectionstring" value = "Server = LENOVO-THINK; database = UDS; user id = sa; Password =; connection timeout = 60"/>

 

This is in the web. in the config file, an app key "connectionstring" is created, and the required database connection string (value) is saved. In this way, when you create a connection in webform, you only need to read the connectionstring value. The specific code is as follows.

Dim connstr as string

Connstring = configurationsettings. receivetting ("connectionstring ")

Dim cnsqlserver as new sqlconnection (connstr)

Cnsqlserver. Open

 

2. Use the oledb. NET database provider to connect to access

Dim cnaccess as new oledbconnection

Cnaccess. connectionstring = "provider = Microsoft. Jet. oledb.4.0; Data Source = C:/webdb/UDS. mdb"

Cnaccess. open ();

Cnaccess. Close ();

 

 

3. Use the oralce. NET database provider to connect to Oracle

First of all, I want to tell you not to think that there is anything profound and profound about connecting to Oracle. In fact, there are not many connections to SQL Server.

<Connectionstrings>
<Add name = "applicationservices"
Connectionstring = "Data Source =./sqlexpress; Integrated Security = sspi; attachdbfilename = | datadirectory |/aspnetdb. MDF; user instance = true"
Providername = "system. Data. sqlclient"/>

<Add name = "mitaczp" connectionstring = "Data Source = hrweb_11g; user = HR; Password = HR;" providername = "system. Data. oracleclient"/>
</Connectionstrings>

 

 

After reading my blog, please leave a message and I will reply as far as I can.

 

 

 

 

 

 

 

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.