web| Data | database | database connection
In the settings of the Web program in asp.net we must use the Web.config to store the database connection Word. Actually, it's a
Good practice, because it can save us a lot of trouble can also help us avoid unnecessary dislocation, yes, in many cases
That's what I do. It records this information through XML. Specifically in <appSettings>....</appSettings> this
Tag. Here is an example of an Oracle, as follows:
<appSettings>
<add key= "oracleconnectionstring" value= "PROVIDER=ORAOLEDB.ORACLE.1;
Persist Security Info=false; Password=blah; User id=greg;data source=sph; "/>
<add key= "sqlConnectionString" value= "Data source=sql1;initial catalog=id_v;
Integrated security=sspi;persist security Info=false;workstation id=th03d374;
Packet size=4096 "/>
<appSettings>
And in your application you just have to write it, as follows:
String conn = configurationsettings.appsettings["Oracleconnectionstring"];
OleDbConnection myconnection = new OleDbConnection (conn);
It's easy, isn't it? Do not have to enter the same connection word every time, do not remember the annoying information, only need a good memory
Name is OK.
Okay, I'm here to give you some other connection words.
MySQL's connection word:
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 ()
JET OLE DB
' 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=mydatasourcename;" & _
"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 ();