Usage of database connection words in Web. config

Source: Internet
Author: User
Author: unknown. Please contact me quickly. We must use WEB in the settings of the Web program in asp.net. config to store database connection words. in fact, this is a good practice, because it saves us a lot of trouble and helps us avoid unnecessary misplacement. it records this information through XML. specifically in...

Author: unknown. Please contact me quickly. We must use WEB in the settings of the Web program in asp.net. config to store database connection words. in fact, this is a good practice, because it saves us a lot of trouble and helps us avoid unnecessary misplacement. it records this information through XML. specifically in...

Author: Unknown please contact me quickly

In the WEB program settings in asp.net, we must use Web. config to store database connection words. in fact, this is a good practice, because it saves us a lot of trouble and helps us avoid unnecessary misplacement. it records this information through XML. specifically in ....Here, an ORACLE example is as follows:



Persist Security Info = False; Password = blah; User ID = greg; Data Source = 7d; "/>
Integrated security = SSPI; persist security info = False; workstation id = TH03D374;
Packet size = 4096 "type =" codeph "text ="/codeph "/>



In your application, you only need to write it like this, as shown below:

String conn = ConfigurationSettings. deleettings ["ORACLEConnectionString"];
OleDbConnection myConnection = new OleDbConnection (conn );

Is it easy? You don't have to enter the same connection word every time, or remember the nasty information. You just need to enter a memorable name. Well, I will give some other connection words below:

MYSQL connection words:
ConnectionString = "Data Source = localhost;" +
"Database = mySQLDatabase;" +
"User ID = myUsername;" +
"Password = myPassword;" +
"Command Logging = false ";
Ole db:
Ibm as/400 OLE DB

'Vb. NET
Dim oOleDbConnection As OleDb. OleDbConnection
Dim sConnString As String = _
"Provider = IBMDA400.DataSource. 1 ;"&_
"Data source = myAS400DbName ;"&_
"User Id = myUsername ;"&_
"Password = myPassword"
OOleDbConnection = New OleDb. OleDbConnection (sConnString)
OOleDbConnection. Open ()

The

'Vb. NET
Dim oOleDbConnection As OleDb. OleDbConnection
Dim sConnString As String = _
"Provider = Microsoft. Jet. OLEDB.4.0 ;"&_
"Data Source = C:/myPath/myJet. mdb ;"&_
"User ID = Admin ;"&_
"Password ="
OOleDbConnection = New OleDb. OleDbConnection (sConnString)
OOleDbConnection. Open ()

Oracle OLE DB

'Vb. NET
Dim oOleDbConnection As OleDb. OleDbConnection
Dim sConnString As String = _
"Provider = OraOLEDB. Oracle ;"&_
"Data Source = MyOracleDB ;"&_
"User ID = myUsername ;"&_
"Password = myPassword"
OOleDbConnection = New OleDb. OleDbConnection (sConnString)
OOleDbConnection. Open ()

SQL Server OLE DB

'Vb. NET
Dim oOleDbConnection As OleDb. OleDbConnection
Dim sConnString As String = _
"Provider = sqloledb ;"&_
"Data Source = myServerName ;"&_
"Initial Catalog = myDatabaseName ;"&_
"User Id = myUsername ;"&_
"Password = myPassword"
OOleDbConnection = New OleDb. OleDbConnection (sConnString)
OOleDbConnection. Open ()

Sybase ASE OLE DB

'Vb. NET
Dim oOleDbConnection As OleDb. OleDbConnection
Dim sConnString As String = _
"Provider = Sybase ase ole db Provider ;"&_
"Data Source = mydomaincename ;"&_
"Server Name = MyServerName ;"&_
"Database = MyDatabaseName ;"&_
"User ID = myUsername ;"&_
"Password = myPassword"
OOleDbConnection = New OleDb. OleDbConnection (sConnString)
OOleDbConnection. Open ()

SQL Server in System. Data. SqlClient

SqlConnection oSQLConn = new SqlConnection ();
OSQLConn. ConnectionString = "Data Source = (local);" +
"Initial Catalog = mySQLServerDBName;" +
"Integrated Security = SSPI ";
OSQLConn. Open ();

This is all written in VB. NET. I hope to help my friends who use VB to write ASP. NET.

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.