Usage of database connection words in web.config

xiaoxiao2021-03-14  182

In the setting of the web program in the ASP.NET we must use Web.config to store database connection words. In fact this is

Very good practice, because you can save us a lot of troubles can also help us avoid unnecessary misplacement, there are many cases

I am doing this. It records this information through XML. The specific is in .... this

Tagged in the mark. Please see an example of an Oracle as follows:

And you can write like this in your app, 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 nasty information, just need a good book.

Name can be.

Ok, I am here to give some 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 = mysqlserdbname;" "integrated security = sspi"; osqlconn.open ();

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

New Post(0)