Usage of database connection words in web.config

xiaoxiao2021-03-06  112

Author: Unknown Please click here to contact me in setting WEB program in asp.net we have to use to store the database connection Web.config word in fact it is a good practice, because we can save a lot of trouble yet. Can help us avoid unnecessary misplaced, I am doing this. It records this information through XML. The specific is

....

This tag is recorded. Here, please see an example of Oracle as follows:

, in your application, you only Write, you can, as follows:

String conn = configurationSettings.appsettings ["OracleConnectionString"]; OLEDBCONNECTION MyConnection = New OLEDBCONNECTION (CONN);

Very easy? Don't you need to enter the same connection word every time, don't remember those hate information, just need a good name. Well, I will give other connection words:

Mysql connection word: connectionString = "Data Source = localhost;" "Database = mysqldatabase;" "user ID = myusername;" "password = mypassword;" "Command logging = false"; OLE DB: IBM AS / 400 OLE DB

'VB.NETDim oOleDbConnection As OleDb.OleDbConnectionDim sConnString As String = _ "Provider = IBMDA400.DataSource.1;" & _ "Data source = myAS400DbName;" & _ "User Id = myUsername;" & _ "Password = myPassword" oOleDbConnection = New OLEDB.OLDBConnection (Sconnstring) Ooledbconnection.Open () Jet OLE DB

'Vb.netdim ooledbconnection as oledb.oledbconnectiondim sconnstring as string = _ "provider = microsoft.jet.Oledb.4.0;" & _ "data source = c: /mypath/myjet.mdb;" & _ "user ID = admin; "& _" Password = " 'VB.NETDim oOleDbConnection = New OleDb.OleDbConnection (sConnString) oOleDbConnection.Open () Oracle OLE DB of oOleDbConnection As OleDb.OleDbConnectionDim sConnString As String = _" Provider = OraOLEDB.Oracle; "& _" Data Source = Myoracledb; "& _" User ID = myusername; "& _" Password = mypassword "ooledbconnection = new oledb.oledbconnection (sconnstring) oledbconnection.open () SQL Server Ole DB

'VB.NETDim oOleDbConnection As OleDb.OleDbConnectionDim sConnString As String = _ "Provider = sqloledb;" & _ "Data Source = myServerName;" & _ "Initial Catalog = myDatabaseName;" & _ "User Id = myUsername;" & _ " Password = mypassword "ooledbconnection = new oledb.oledbconnection (sconnstring) oledbconnection.open () Sybase ASE OLE DB

'VB.NETDim oOleDbConnection As OleDb.OleDbConnectionDim sConnString As String = _ "Provider = Sybase ASE OLE DB Provider;" & _ "Data Source = MyDataSourceName;" & _ "Server Name = MyServerName;" & _ "Database = MyDatabaseName;" & _ "User ID = myusername;" & _ "Password = mypassword" ooledbconnection = new oledb.oledbconnection (sconnstring) oledbconnection.open () SQL Server is in system.data.sqlclient

SqlConnection oSQLConn = new SqlConnection (); oSQLConn.ConnectionString = "Data Source = (local);" "Initial Catalog = mySQLServerDBName;" "Integrated Security = SSPI"; oSQLConn.Open (); herein are used VB.NET Written, I hope to help friends with VB written asp.net.

转载请注明原文地址:https://www.9cbs.com/read-101728.html

New Post(0)