Menghubungkan VB dengan semua database

Menghubungkan VB dengan semua database

1. SQL Server
  • ODBC Standard Security:"Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"
    Trusted connection:"Driver={SQL Server};Server=Aron1;Database=pubs;
    Trusted_Connection=yes;"
    Prompt for username and password:oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Driver={SQL Server};Server=Aron1;DataBase=pubs;"
  • OLE DB, OleDbConnection (.NET)
    Standard Security:
    "Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
    Trusted Connection:"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
    (use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)
    Prompt for username and password:oConn.Provider = "sqloledb"oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Data Source=Aron1;Initial Catalog=pubs;"
    Connect via an IP address:
    "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
    (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))
  • SqlConnection (.NET)Standard Security:
    "Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;" - or -
    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"

    (both connection strings produces the same result)

    Trusted Connection:"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;" - or -"Server=Aron1;Database=pubs;Trusted_Connection=True;"

    (both connection strings produces the same result)
    (use serverName\instanceName as Data Source to use an specifik SQLServer instance,
    only SQLServer2000)
    Connect via an IP address:"Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
    (DBMSSOCN=TCP/IP instead of Named Pipes,
    at the end of the Data Source is the port to use (1433 is the default))
    Declare the SqlConnection:C#:using System.Data.SqlClient;SqlConnection oSQLConn = new SqlConnection();oSQLConn.ConnectionString="my connection string";oSQLConn.Open();
    VB.NET:Imports System.Data.SqlClientDim oSQLConn As SqlConnection = New SqlConnection()oSQLConn.ConnectionString="my connection string"oSQLConn.Open()
  • Data ShapeMS Data Shape"Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=Aron1;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
2.

SQL Server 2005

  • SQL Native Client ODBC Driver
    Standard security:
    "Driver={SQL Native Client};Server=Aron1;Database=pubs;UID=sa;PWD=asdasd;"

    Trusted connection:
    "Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;"

    EquivalentsIntegrated Security=SSPI equals Trusted_Connection=yes

    Prompt for username and password:oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Driver={SQL Native Client};Server=Aron1;DataBase=pubs;"

    Enabling MARS (multiple active result sets):
    "Driver={SQL Native Client};Server=Aron1;Database=pubs;

    Trusted_Connection=yes;MARS_Connection=yes"

    EquivalentsMultipleActiveResultSets=true equals MARS_Connection=yes


    Encrypt data sent over network:
    "Driver={SQL Native Client};Server=Aron1;Database=pubs;

    Trusted_Connection=yes;Encrypt=yes"
    Attach a database file on connect to a local SQL Server Express instance:
    "Driver={SQL Native Client};Server=.\SQLExpress;

    AttachDbFilename=c:\asd\qwe\mydbfile.mdf;

    Database=dbname;Trusted_Connection=Yes;"

    - or -

    "Driver={SQL Native Client};Server=.\SQLExpress;

    AttachDbFilename=DataDirectorymydbfile.mdf;

    Database=dbname;Trusted_Connection=Yes;"

    (use DataDirectory when your database file resides in the data directory)

    Why is the "Database" parameter needed?
    Answer:
    If the database was previously attached, SQL Server does not reattach it
    (it uses the attached database as the default for the connection).

    (the package contains booth the ODBC driver and the OLE DB provider)
    Using SQL Server 2005 Express? Don't miss the server name syntax:

    SERVERNAME\SQLEXPRESS (Substitute "SERVERNAME" with the name of the computer)
  • SQL Native Client OLE DB Provider
    Standard security:

    "Provider=SQLNCLI;Server=Aron1;Database=pubs;
    UID=sa;PWD=asdasd;"
    Trusted connection:"Provider=SQLNCLI;Server=Aron1;Database=pubs;
    Trusted_Connection=yes;"
    Equivalents
    Integrated Security=SSPI equals Trusted_Connection=yes


    Prompt for username and password:oConn.Properties("Prompt") = adPromptAlwaysoConn.Open "Provider=SQLNCLI;Server=Aron1;DataBase=pubs;"
    Enabling MARS (multiple active result sets):"Provider=SQLNCLI;Server=Aron1;Database=pubs;
    Trusted_Connection=yes;MarsConn=yes"

    Equivalents

    MarsConn=yes equals MultipleActiveResultSets=true equals MARS_Connection=yes


    Encrypt data sent over network:"Provider=SQLNCLI;Server=Aron1;Database=pubs;
    Trusted_Connection=yes;Encrypt=yes"

    Attach a database file on connect to a local SQL Server Express instance:"Provider=SQLNCLI;Server=.\SQLExpress;
    AttachDbFilename=c:\asd\qwe\mydbfile.mdf;
    Database=dbname;Trusted_Connection=Yes;"
    - or -
    "Provider=SQLNCLI;Server=.\SQLExpress;
    AttachDbFilename=DataDirectorymydbfile.mdf;
    Database=dbname;Trusted_Connection=Yes;"

    (use DataDirectory when your database file resides in the data directory)

    Why is the "Database" parameter needed?
    Answer: If the database was previously attached,
    SQL Server does not reattach it
    (it uses the attached database as the default for the connection).



    (the package contains booth the ODBC driver and the OLE DB provider)
    Using SQL Server 2005 Express? Don't miss the server name syntax:
    SERVERNAME\SQLEXPRESS (Substitute "SERVERNAME" with the name of the computer)

  • SqlConnection (.NET)
    Standard Security:
    "Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"

    - or -

    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"

    (both connection strings produces the same result)

    Trusted Connection:"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"

    - or -

    "Server=Aron1;Database=pubs;Trusted_Connection=True;"

    (both connection strings produces the same result)

    (use serverName\instanceName as Data Source to use an specifik SQLServer instance)

    Connect via an IP address:"Data Source=190.190.200.100,1433;
    Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"

    (DBMSSOCN=TCP/IP instead of Named Pipes,
    at the end of the Data Source is the port to use (1433 is the default))

    Enabling MARS (multiple active result sets):"Server=Aron1;Database=pubs;
    Trusted_Connection=True;MultipleActiveResultSets=true"

    Note! Use ADO.NET 2.0 for MARS functionality.
    MARS is not supported in ADO.NET 1.0 nor ADO.NET 1.1
    Streamline your Data Connections by Moving to MARS, by Laurence Moroney, DevX.com >>

    Attach a database file on connect to a local
    SQL Server Express instance:
    "Server=.\SQLExpress;
    AttachDbFilename=c:\asd\qwe\mydbfile.mdf;
    Database=dbname;
    Trusted_Connection=Yes;"
    - or -
    "Server=.\SQLExpress;
    AttachDbFilename=DataDirectorymydbfile.mdf;
    Database=dbname;
    Trusted_Connection=Yes;"

    (use DataDirectory when your database file resides in the data directory)
    Why is the "Database" parameter needed?
    Answer: If the database was previously attached,
    SQL Server does not reattach it (
    it uses the attached database as the default for the connection).

    Using "User Instance" on a local SQL Server Express instance:"Data Source=.\SQLExpress;integrated security=true;
    attachdbfilename=DataDirectory\mydb.mdf;user instance=true;"

    The "User Instance" functionality creates a new SQL Server
    instance on the fly during connect. This works only on a local SQL Server 2005
    instance and only when connecting using windows authentication over local named pipes.
    The purpose is to be able to create a full rights SQL Server instance to a user
    with limited administrative rights on the computer.
    To enable the functionality: sp_configure 'user instances enabled','1' (0 to disable)
    Using SQL Server 2005 Express? Don't miss the server name syntax:
    SERVERNAME\SQLEXPRESS (Substitute "SERVERNAME" with the name of the computer)

  • Context Connection - connecting to "self" from within your
    CLR stored prodedure/function
    C#:

    using(SqlConnection connection = new SqlConnection("context connection=true"))
    { connection.Open();
    // Use the connection
    }

    Visual Basic:
    Using connection as new SqlConnection("context connection=true")
    connection.Open() ' Use the connection
    End Using
    The context connection lets you execute Transact-SQL statements
    in the same context (connection) that your code was invoked in the first place.



3. Access
  • ODBCStandard Security:
    "Driver={Microsoft Access Driver (*.mdb)};
    Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"

    Workgroup:
    "Driver={Microsoft Access Driver (*.mdb)};
    Dbq=C:\mydatabase.mdb;SystemDB=C:\mydatabase.mdw;"
    Exclusive:"Driver={Microsoft Access Driver (*.mdb)};
    Dbq=C:\mydatabase.mdb;Exclusive=1;Uid=admin;Pwd="

  • OLE DB, OleDbConnection (.NET)Standard security:
    "Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"

    Workgroup (system database):
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;"

    With password:
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"

4. Oracle
  • ODBCNew version:
    "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;
    Uid=Username;Pwd=asdasd;"
    Old version:"Driver={Microsoft ODBC Driver for Oracle};
    ConnectString=OracleServer.world;
    Uid=myUsername;Pwd=myPassword;"

  • OLE DB, OleDbConnection (.NET)Standard security:"Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;"

    This one's from Microsoft, the following are from Oracle
    Standard Security:"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"
    Trusted Connection:"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;"

  • OracleConnection (.NET)
    Standard:"Data Source=MyOracleDB;Integrated Security=yes;"

    This one works only with Oracle 8i release 3 or later
    Specifying username and password:"Data Source=MyOracleDB;User Id=username;Password=passwd;Integrated Security=no;"

    This one works only with Oracle 8i release 3 or later

  • Declare the OracleConnection:C#:using System.Data.OracleClient;
    OracleConnection oOracleConn = new OracleConnection();
    oOracleConn.ConnectionString = "my connection string";
    oOracleConn.Open();
    VB.NET:Imports System.Data.OracleClient
    Dim oOracleConn As OracleConnection = New OracleConnection()
    OracleConn.ConnectionString = "my connection string"
    oOracleConn.Open()

    Missing the System.Data.OracleClient namespace?
    Download .NET Managed Provider for Oracle >>Great article! "Features of Oracle Data Provider for .NET" by Rama Mohan G. at C# Corner

  • Core Labs OraDirect (.NET)Standard:"User ID=scott; Password=tiger; Host=ora; Pooling=true; Min Pool Size=0;Max Pool Size=100; Connection Lifetime=0"

    Read more at
    Core Lab and the product page.

  • Data ShapeMS Data Shape:"Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw"


5. MySQL
  • MyODBCMyODBC 2.50 Local database:
    "Driver={mySQL};Server=localhost;
    Option=16834;Database=mydatabase;"

    MyODBC 2.50 Remote database:
    "Driver={mySQL};Server=data.domain.com;
    Port=3306;Option=131072;Stmt=;
    Database=my-database;Uid=username;Pwd=password;"

    MyODBC 3.51 Local database:
    "DRIVER={MySQL ODBC 3.51 Driver};
    SERVER=localhost;DATABASE=myDatabase;
    USER=myUsername;
    PASSWORD=myPassword;OPTION=3;"

    MyODBC 3.51 Remote database:
    "DRIVER={MySQL ODBC 3.51 Driver};
    SERVER=data.domain.com;
    PORT=3306;DATABASE=myDatabase; USER=myUsername;PASSWORD=myPassword;OPTION=3;"

  • OLE DB, OleDbConnection (.NET)Standard:
    "Provider=MySQLProv;Data Source=mydb;
    User Id=UserName;Password=asdasd;"
    Connector/Net 1.0 (.NET)
    Standard:"Server=Server;Database=Test;Uid=UserName;Pwd=asdasd;"

    Download the driver at
    MySQL Developer Zone.
    Specifying port:"Server=Server;Port=1234;Database=Test;
    Uid=UserName;Pwd=asdasd;"

    Default port is 3306. Enter value -1 to use a named pipe connection.
    Declare the MySqlClient connection:C#:using MySql.Data.MySqlClient;
    MySqlConnection oMySqlConn = new MySqlConnection();
    oMySqlConn.ConnectionString = "Server=Server;Database=Test;Uid=UserName;Pwd=asdasd;";
    oMySqlConn.Open();
    VB.NET:Imports MySql.Data.MySqlClient
    Dim oMySqlConn As MySqlConnection = New MySqlConnection()
    oMySqlConn.ConnectionString = "Server=Server;Database=Test;Uid=UserName;Pwd=asdasd;"
    oMySqlConn.Open()

  • MySqlConnection (.NET)eInfoDesigns.dbProvider:
    "Data Source=server;Database=mydb;User ID=username;Password=pwd;Command Logging=false"

    This one is used with
    eInfoDesigns dbProvider, an add-on to .NET
    Declare the MySqlConnection:
    C#:
    using eInfoDesigns.dbProvider.MySqlClient;
    MySqlConnection oMySqlConn = new MySqlConnection();
    oMySqlConn.ConnectionString = "my connection string";
    oMySqlConn.Open();
    VB.NET:Imports eInfoDesigns.dbProvider.MySqlClient
    Dim oMySqlConn As MySqlConnection = New MySqlConnection()
    oMySqlConn.ConnectionString = "my connection string"
    oMySqlConn.Open()

  • SevenObjects MySqlClient (.NET)Standard:
    "Host=server; UserName=myusername; Password=mypassword;Database=mydb;"

    This is a freeware ADO.Net data provider from
    SevenObjects

  • Core Labs MySQLDirect (.NET)Standard:"User ID=root; Password=pwd; Host=localhost; Port=3306; Database=test;
    Direct=true; Protocol=TCP; Compress=false; Pooling=true; Min Pool Size=0;
    Max Pool Size=100; Connection Lifetime=0"
6.Interbase
  • ODBC, Easysoft
    Local computer:
    "Driver={Easysoft IB6 ODBC};
    Server=localhost;Database=localhost:C:\mydatabase.gdb;
    Uid=username;Pwd=password"

    Remote Computer:
    "Driver={Easysoft IB6 ODBC};
    Server=ComputerName;
    Database=ComputerName:C:\mydatabase.gdb;
    Uid=username;Pwd=password"

  • ODBC, IntersolvLocal computer:
    "Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};Server=localhost;Database=localhost:C:\mydatabase.gdb;
    Uid=username;Pwd=password"

    Remote Computer:
    "Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};
    Server=ComputerName;
    Database=ComputerName:C:\mydatabase.gdb;
    Uid=username;Pwd=password"

    This driver are provided by
    DataDirect Technologies >> (formerly Intersolv)

  • OLE DB, SIBPROviderStandard:
    "provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA;password=masterkey"

    Specifying character set:
    "provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA;password=masterkey;character set=ISO8859_1"

    Specifying role:
    "provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA;password=masterkey;role=DIGITADORES"

Komentar