ADO.NET

ADO.NET Projects

ADO.NET Project 1

ADO.NET Examples

Examples

Connecting to Various Data Sources
Previous Home Next

There are following way to connect to a Microsoft SQL database and open and close a connection:

  1. Connecting to SQL Server in C#:
  2. 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#
  2. OleDbConnection conn = new OleDbConnection
    ("Provider=Microsoft.Jet.OLEDB.4.0;" 
    +"Data Source=c:\\emp.mdb;" +
    "User Id=admin;" + "Password=;" );
    conn.Open();
    conn.Close();
    
  3. Connecting to a Microsoft Access Database in Visual Basic .NET
  4. OleDbConnection conn = new OleDbConnection
    ("Provider=Microsoft.Jet.OLEDB.4.0;" 
    +"Data Source=c:\\emp.mdb;" +
    "User Id=admin;" + "Password=;" );
    conn.Open();
    conn.Close();
    

     

  5. Connecting to an Oracle Database in C#
  6. OleDbConnection conn = new OleDbConnection( _
                   "Provider=OraOLEDB.Oracle" + _
                   "Data Source=DataBasename" + _
                          "User Id=username;" + _
                          "Password=password;" );
    conn.Open();
    conn.Close();
    
  7. Connecting to an Oracle Database in Visual Basic .NET
  8. Dim conn as OleDbConnection = New OleDbConnection( _
                          "Provider=OraOLEDB.Oracle" + _
                          "Data Source=DataBasename" + _
                                 "User Id=username;" + _
                                  "Password=password;" )
    conn.Open()
    conn.Close()
    
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback:
>