首页 > 开发 > 综合 > 正文

Connection Strings

2024-07-21 02:22:29
字体:
来源:转载
供稿:网友
  • 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") = adpromptalways
        oconn.open "driver={sql server};server=aron1;database=pubs;"

    • oledb, 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") = adpromptalways
        oconn.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;"

      • trusted connection:
        "data source=aron1;initial catalog=pubs;integrated security=sspi;"
        (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 connectionstring";
        osqlconn.open();

        vb.net:
        imports system.data.sqlclient
        dim osqlconn as sqlconnection = new sqlconnection()
        osqlconn.connectionstring="my connectionstring"
        osqlconn.open()

    • data shape

      • ms data shape
        "provider=msdatashape;data provider=sqloledb;data source=aron1;initial catalog=pubs;user id=sa;password=asdasd;"

    • read more

      • how to define wich network protocol to use

        • example:
          "provider=sqloledb;data source=190.190.200.100,1433;network library=dbmssocn;initial catalog=pubs;user id=sa;password=asdasd;"

          namenetwork librarydbnmpntwwin32 named pipesdbmssocnwin32 winsock tcp/ipdbmsspxnwin32 spx/ipxdbmsvinnwin32 banyan vinesdbmsrpcnwin32 multi-protocol (windows rpc)

          important note!
          when connecting through the sqloledb provider use the syntax network library=dbmssocn
          and when connecting through msdasql provider use the syntax network=dbmssocn

      • all sqlconnection connectionstring properties

        • this table shows all connectionstring properties for the ado.net sqlconnection object. most of the properties are also used in ado. all properties and descriptions is from msdn.

          namedefaultdescriptionapplication name the name of the application, or '.net sqlclient data provider' if no application name is provided.attachdbfilename
          -or-
          extended properties
          -or-
          initial file name the name of the primary file, including the full path name, of an attachable database. the database name must be specified with the keyword 'database'.connect timeout
          -or-
          connection timeout15the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.connection lifetime0when a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime. useful in clustered configurations to force load balancing between a running server and a server just brought on-line.connection reset'true'determines whether the database connection is reset when being removed from the pool. setting to 'false' avoids making an additional server round-trip when obtaining a connection, but the programmer must be aware that the connection state is not being reset.current language the sql server language record name.data source
          -or-
          server
          -or-
          address
          -or-
          addr
          -or-
          network address the name or network address of the instance of sql server to which to connect.enlist'true'when true, the pooler automatically enlists the connection in the creation thread's current transaction context.initial catalog
          -or-
          database the name of the database.integrated security
          -or-
          trusted_connection'false'whether the connection is to be a secure connection or not. recognized values are 'true', 'false', and 'sspi', which is equivalent to 'true'.max pool size100the maximum number of connections allowed in the pool.min pool size0the minimum number of connections allowed in the pool.network library
          -or-
          net'dbmssocn'the network library used to establish a connection to an instance of sql server. supported values include dbnmpntw (named pipes), dbmsrpcn (multiprotocol), dbmsadsn (apple talk), dbmsgnet (via), dbmsipcn (shared memory) and dbmsspxn (ipx/spx), and dbmssocn (tcp/ip).
          the corresponding network dll must be installed on the system to which you connect. if you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used.packet size8192size in bytes of the network packets used to communicate with an instance of sql server.password
          -or-
          pwd the password for the sql server account logging on.persist security info'false'when set to 'false', security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. resetting the connection string resets all connection string values including the password.pooling'true'when true, the sqlconnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool.user id the sql server login account.workstation idthe local computer namethe name of the workstation connecting to sql server.

          note
          use ; to separate each property.
          if a name occurs more than once, the value from the last one in the connectionstring will be used.
          if you are building your connectionstring in your app using values from user input fields, make sure the user can't change the connectionstring by inserting an additional property with another value within the user value.
    • access
      • odbc

        • standard security:
          "driver={microsoft access driver (*.mdb)};dbq=/somepath/mydb.mdb;uid=admin;pwd=asdasd;"

        • workgroup:
          "driver={microsoft access driver (*.mdb)};dbq=/somepath/mydb.mdb;systemdb=/somepath/mydb.mdw;","admin", ""

      • oledb, oledbconnection (.net)

        • standard security:
          "provider=microsoft.jet.oledb.4.0;data source=/somepath/mydb.mdb;user id=admin;password=asdasd;"

        • workgroup (system database):
          "provider=microsoft.jet.oledb.4.0;data source=/somepath/mydb.mdb;jet oledb:system database=system.mdw;","admin", ""

        • with password:
          "provider=microsoft.jet.oledb.4.0;data source=/somepath/mydb.mdb;jet oledb:database password=mydbpassword;","admin", ""

    • oracle
      • odbc

        • new 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;"

      • oledb, 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=oracle8i;integrated security=yes";
          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 connectionstring";
          ooracleconn.open();

          vb.net:
          imports system.data.oracleclient
          dim ooracleconn as oracleconnection = new oracleconnection()
          ooracleconn.connectionstring = "my connectionstring"
          ooracleconn.open()

      • data shape

        • ms data shape:
          "provider=msdatashape.1;persist security info=false;data provider=msdaora;data source=orac;user id=username;password=mypw"

    • mysql
      • odbc

        • local database:
          "driver={mysql};server=mysrvname;option=16834;database=mydatabase;"

        • remote database:
          "driver={mysql};server=data.domain.com;port=3306;option=131072;stmt=;database=my-database;uid=username;pwd=password;"

      • oledb, oledbconnection (.net)

        • standard:
          "provider=mysqlprov;data source=mydb;user id=username;password=asdasd;"
      • mysqlconnection (.net)

        • eid:
          "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 eid.mysqlclient;
          mysqlconnection omysqlconn = new mysqlconnection();
          omysqlconn.connectionstring = "my connectionstring";
          omysqlconn.open();

          vb.net:
          imports eid.mysqlclient
          dim omysqlconn as mysqlconnection = new mysqlconnection()
          omysqlconn.connectionstring = "my connectionstring"
          omysqlconn.open()

    • ibm db2
      • oledb, oledbconnection (.net) from ms

        • tcp/ip:
          "provider=db2oledb;network transport library=tcpip;network address=xxx.xxx.xxx.xxx;initial catalog=myctlg;package collection=mypkgcol;default schema=schema;user id=myuser;password=mypw"

        • appc:
          "provider=db2oledb;appc local lu alias=myalias;appc remote lu alias=myremote;initial catalog=myctlg;package collection=mypkgcol;default schema=schema;user id=myuser;password=mypw"

    • sybase
      • odbc

        • standard:
          "driver={sybase system 11};srvr=aron1;uid=username;pwd=password;"

        • intersolv 3.10:
          "driver={intersolv 3.10 32-bit sybase};srvr=aron1;uid=username;pwd=password;"

    • informix
      • odbc

        • informix 3.30:
          "dsn='';driver={informix 3.30 32 bit};host=hostname;server=myserver;service=service-name;protocol=olsoctcp;database=mydb;uid=username;pwd=mypwd

        • informix-cli 2.5:
          "driver={informix-cli 2.5 (32 bit)};server=myserver;database=mydb;uid=username;pwd=mypwd"

    • dsn
      • odbc

        • dsn:
          "dsn=mydsn;uid=username;pwd=;"

        • file dsn:
          "filedsn=c:/mydata.dsn;uid=username;pwd=;"

    • excel
      • odbc

        • standard:
          "driver={microsoft excel driver (*.xls)};driverid=790;dbq=c:/myexcel.xls;defaultdir=c:/mypath;"

      • ole db

        • standard:
          "provider=microsoft.jet.oledb.4.0;data source=c:/myexcel.xls;extended properties=excel 8.0;hdr=yes;"
          "hdr=yes;" indicates that the first row contains columnnames, not data
    • dbf / foxpro
      • odbc

        • standard:
          "driver={microsoft dbase driver (*.dbf)};driverid=277;dbq=c:/mydbpath;"

      • oledb, oledbconnection (.net)

        • standard:
          "provider=microsoft.jet.oledb.4.0;data source=c:/folder;extended properties=dbase iv;user id=admin;password="

    • pervasive
      • odbc

        • standard:
          "driver={pervasive odbc client interface};servername=srvname;[email protected]"

    • udl
      • udl

        • udl:
          "file name=c:/mydatalink.udl;"
    • 本文来源于网页设计爱好者web开发社区http://www.html.org.cn收集整理,欢迎访问。
    • 发表评论 共有条评论
      用户名: 密码:
      验证码: 匿名发表