Web. config data source configuration

Source: Internet
Author: User
Tags oracleconnection connectionstrings
1. Use ODBC to connect to the data source
Control Panel → Administrative Tools → data source ODBC → system DSN → add → drive do Microsoft Access (*. mdb) → select (example. mdb) → complete
In web. config:
<Connectionstrings>
<Add name = "connection" connectionstring = "DSN = example"/>
</Connectionstrings>
In page_load:
Odbcconnection con = new odbcconnection (configurationmanager. connectionstrings ["connection"]. connectionstring );

2. SQL Server Data Source
In web. config:
<Connectionstrings>
<Add name = "connectionsqlserver" connectionstring = "Server = (local); database = northwind; uid = sa; Pwd = sa"/>
</Connectionstrings>
In page_load:
Sqlconnection con = new sqlconnection (configurationmanager. connectionstrings ["connectionsqlserver"]. connectionstring );
Con. connectiontimeout. tostring (); // The timeout value.

3. ole db data source (ACCESS)
In web. config:
<Connectionstrings>
<Add name = "connectionoledb" connectionstring = "provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ example. mdb"/>
</Connectionstrings>
In page_load:
Oledbconnection con = new oledbconnection (configurationmanager. connectionstrings ["connectionoledb"]. connectionstring );

4. oracle Data Source
the Program provided by Oracle is not. by default, the dynamic link library is introduced:
website → add reference →. net → system. data. oracleclient
Web. config:



In page_load:
oracleconnection con = new oracleconnection (configurationmanager. connectionstrings ["connectionoracle"]. connectionstring);

5. sqldatasource and accessdatasource control data source
the sqldatasource control provides three authentication modes: Windows mode, SQL Server mode, and Hybrid Authentication mode
Windows mode web. config:



SQL SERVER mode web. config:



accessdatasource is similar to sqldatasource, so it is omitted

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.