Connecting to Various Data Sources
There are following way to connect to a Microsoft SQL database and open and close a connection:
1)Connecting to SQL Server in C#:
SqlConnection conn = new SqlConnection("Initial Catalog=computer;Server=(local);UID=sa;PWD=");
conn.Open();
conn.Close();
|
There are following way to connect to a Microsoft Jet OLE DB provider. and open and close a connection:-
1)Connecting to a Microsoft Access Database in C#
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source=c:\\emp.mdb;" +
"User Id=admin;" + "Password=;" );
conn.Open();
conn.Close();
|
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;"
+"Data Source=c:\\emp.mdb;" +
"User Id=admin;" + "Password=;" );
conn.Open();
conn.Close();
2)Connecting to a Microsoft Access Database in Visual Basic .NET
Dim conn as OleDbConnection = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source=c:\Emp.mdb;" + _
"User Id=admin;" + _
"Password=;" )
conn.Open()
conn.Close()
|
3)Connecting to an Oracle Database in C#
OleDbConnection conn = new OleDbConnection( _
"Provider=OraOLEDB.Oracle" + _
"Data Source=DataBasename" + _
"User Id=username;" + _
"Password=password;" );
conn.Open();
conn.Close();
|
4) Connecting to an Oracle Database in Visual Basic .NET
Dim conn as OleDbConnection = New OleDbConnection( _
"Provider=OraOLEDB.Oracle" + _
"Data Source=DataBasename" + _
"User Id=username;" + _
"Password=password;" )
conn.Open()
conn.Close()
|
No comments:
Post a Comment