ODBC连接字符串全解

合集下载

vc之ODBC连接数据库图文全解

vc之ODBC连接数据库图文全解

vc之ODBC连接数据库图文全解我们在编程时要保存各种实时接收的数据,并为以后的数据再现回放,就应该建立数据文件,而这种数据文件可以用普通文件读写方式,但当数据类型较多且要求随时回放数据时,要求编程时设置较大的动态数组,这会占用较多的系统资源,甚至导致程序崩溃;而利用数据库则可以较好地解决这个问题,我们将数据放到数据源文件中,通过编程接口对其进行访问。

ODBC(开放的数据库连接:Open Database Connectivity)为各种类型的数据库管理系统提供了统一的编程接口,我们在下面的几篇文章中,首先通过实例说明ODBC技术的应用方法,然后说明如何将串口数据实时保存在数据源文件中,这一方面介绍VC中ODBC技术的应用(前面的例子不涉及串口技术,以方便只想了解ODBC技术的读者,又为利用ODBC技术保存串口编程数据提供范例,虽然前面几个例程与串口通讯不相关,但如果对使用数据库不熟悉,也请从前面有耐心地看下去。

1.首先在控制面板中,打开ODBC数据源,点击用户DSN选项,在出现的界面中点击添加,如下图所示:然后,点击完成按钮,出现下图,填入数据源名(可随意取名,本处设为biao)点击确定即可。

2.在ACCESS中创建数据库,本例中为data(只包含number,name,score三列),可从我提供的这个例子下COPY3.建立应用程序项目(1)打开File 菜单的New 选项,选取Projects,选择MFC AppWizard (exe),填入工程名,本例为DATA1(2)把数据库文件data拷入新建的工程目录。

(3)应用程序的类型指定为SDI,在Step2 对话框中选择Header Files Only选项,在Step6是将视图基类指定为CScrollView。

(4)用ClassWizard 创建记录集类。

从Add Class菜单中选择New,并按下图填充对话框:(说明:一个CRecordset对象代表从数据源中查询的一个记录集。

数据库,介绍其连接符的含义及使用方法

数据库,介绍其连接符的含义及使用方法

数据库,介绍其连接符的含义及使用方法ODBC(OpenDatabaseConnectivity):在早期,各个数据库的格式均不统一,为了能处理各种各样的数据库,人们就创建了ODBC这样一个通用的API 库。

但是程序员在开发数据库程序中,仍然感到困难,所以微软公司在DAO、ADO的基础上提出了OLEDB。

OLEDB:一个基于COM的数据存储对象,能提供对所有类型的数据的操作,甚至能在离线的情况下存取数据。

在前面使用DSN数据源时,每次都需要在ODBC数据管理器当中建立一个数据源,然后Web程序就通过ODBC层来与数据库进行通信。

但是OLEDB消除了Web应用程序和数据库之间的ODBC层,从而提高了连接的速度。

由于不同的数据库需要不同的OLEDB驱动程序,所以在使用OLEDB时,需要指定驱动程序。

如果没有指定ASP会使用ODBC驱动程序的默认OLEDB提供程序与ODBC驱动程序进行通信,然后再与数据库进行通信。

可以在微软的网站上下载MicrosoftDataAccessComponents(简称MDAC)2.8软件包,并将其安装在运行IIS或PWS的Windows计算机上,获取用于MicrosoftAccess和SQLServer的OLEDB提供程序。

而Oracle数据库的OLEDB提供程序需要另外从OracleWeb站点下载,该站点需要读者注册为用户才能下载。

(注意:由于OLEDB由微软公司提出,所以只有Windows2000/2003/XP 支持。

)对于Access和SQLServer数据库,连接字符串具有如下语法格式。

ODBC:Driver={Driver(*.mdb)};DBQ=[DSN]OLEDB:Provider=[OLEDBProvider];Server=[ServerName];Database=[Databa seName];UID=[UserID];PWD=[Password]其中涉及的参数解析如下:Provider:该参数指定数据库的OLEDB提供程序。

关于ODBC数据源连接文本

关于ODBC数据源连接文本

关于ODBC数据源连接⽂本关于ODBC数据源连接⽂本 在《外部数据库的连接原理》⼀讲中我们说过,ODBC提供对多种数据库的⽀持,如dBase、Access、MS SQL Server及Oracle,也就是说运⽤ODBC数据源中所提供的连接代码,我们可以实现对多种数据库的连接。

以连接Access数据库为例,ODBC数据源连接⽂本的格式是: “Driver={数据库驱动程序};Dbq=数据库⽂件;” 在以上连接⽂本中,如果数据库跟程序在同⼀⽬录下,或者⽤变量DefaultDir指定了数据库所在⽬录,则数据库⽂件可以不⽤全路径名,如下即可: “ODBC;DBQ=MSAccess.mdb;Driver={Microsoft Access Driver (*.mdb)};” 如下也可: “ODBC;DBQ=MSAccess.mdb;DefaultDir=d:/Downloads/e21;Driver={Microsoft Access Driver (*.mdb)};” 如果数据库跟程序不在同⼀⽬录下,或者没有⽤变量DefaultDir指定数据库所在⽬录,则数据库⽂件需要⽤全路径名,如下: “ODBC;DBQ=E:/Quake III Arena/MSAccess.mdb;Driver={Microsoft Access Driver (*.mdb)};” 以上所说的是连接Access数据库的格式,那么连接其他数据库的ODBC数据源连接⽂本⼜是怎样的?连接不同类型的数据库要使⽤不同的对应驱动程序,没忘记吧!不同的驱动程序当然它们的参数组合也就不同了,每⼀种不同驱动程序都有其特定的的参数形式: ⑴、MS Access ODBC DSNless 连接: ☆、参数:Driver 设置值:{Microsoft Access Driver (*.mdb)} ☆、参数:Dbq 设置值:实际路径⽂件名称 ☆、例句: “Driver={Microsoft Access Driver (*.mdb)};Dbq=c:/somepath/dbname.mdb;Uid=Admin;Pwd=pass; ” ⑵、dBase ODBC DSNless 连接: ☆、参数:Driver 设置值:{Microsoft dBASE Driver (*.dbf)} ☆、参数:Dbq 设置值:实际路径⽂件名称 ☆、例句: “Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=c:/somepath/dbname.dbf; ” ⑶、Oracle ODBC DSNless 连接: ☆、参数:Driver 设置值:{Microsoft ODBC for Oracle} ☆、参数:Dbq 设置值:实际路径⽂件名称 ☆、例句: “Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=admin;Pwd=pass; ” ⑷、MS SQL Server DSNless 连接: ☆、参数:Driver 设置值:{SQL Server}; ☆、参数:Server 设置值:服务器名称 ☆、参数:Database 设置值:数据表名称 ☆、参数:Uid 设置值:⽤户名称 ☆、参数:Pwd 设置值:密码 ☆、例句: “Driver={SQL Server};Server=servername;Database=dbname;Uid=sa;Pwd=pass; ” ⑸、MS Text Driver DSNless 连接: ☆、参数:Driver 设置值:{Microsoft Text Driver (*.txt; *.csv)} ☆、参数:Dbq 设置值:实际路径⽂件名称 ☆、例句: “Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=c:/somepath/;Extensions=asc,csv,tab,txt;Persist Security Info=False;” ⑹、Visual Foxpro DSNless 连接: ☆、参数:Driver 设置值:{Microsoft Visual FoxPro Driver} ☆、参数:SourceType 设置值:DBC ☆、参数:SourceDB 设置值:实际路径⽂件名称 ☆、例句: “Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=c:/somepath/dbname.dbc;Exclusive=No;” ⑺、MySQL DSNless 连接: ☆、参数:Driver 设置值:{mysql} ☆、参数:database 设置值:数据表名称 ☆、参数:uid 设置值:⽤户名称 ☆、参数:pwd 设置值:密码 ☆、例句: “driver={mysql}; database=yourdatabase;uid=username;pwd=password;option=16386”*******************************************************************SQL语⾔简介 在上⼀讲中我们介绍了连接外部数据库的⽅法,那么连接之后怎样对外部数据库进⾏读取、显⽰、增删、更新、查询等操作呢?这些操作需要通过外部数据库等对象调⽤SQL指令才能完成。

ODBC详解

ODBC详解
wColumnIndex, //列的索引
下面对上述步骤做详细的介绍。
5.2.1步骤1:连接数据源
为了连接数据源,必须要建立一个数据源连接的环境句柄。通过调用SQLAllocEnv函数实现对环境句柄的分配,在ODBC 3.0里,这个函数已经被SQLAllocHandle取代,但是熟悉ODBC API的开发人员还是习惯用这个函数建立环境句柄,因为VC++开发平台有一个映射服务,这个服务将程序代码对函数SQLAllocEnv的调用转向对函数SQLAllocHandle的调用。
通过调用如下代码可以通过应用程序动态创建数据源MYDB:
BOOL CreateDSN()
{
char* szDesc;
int mlen;
szDesc=new char[256];
sprintf(szDesc,"DSN=%s: DESCRIPTION=TOC support source: \
DBQ=%s: FIL=MicrosoftAccess: \
{
//执行其它操作
…………
}
retcode = :: SQLExecute (hstmt, (UCHAR*)pszSQL, SQL_NTS );
if(rcode == SQL_SUCCESS) // SQL语句执行成功
{
//执行其它操作
…………
}
5.2.4步骤4:获取结果集
SQL语句执行成功以后,应用程序必须准备接收数据,应用程序需要把SQL语句执行结果绑定到一个本地缓存变量里。但是SQL执行语句执行的结果并不是直接传送给应用程序,而是在应用程序准备接收数据的时候通知驱动程序其已经准备好接收数据,应用程序通过调用SQLFetch函数返回结果集的一行数据。

ODBC连接字符串全解

ODBC连接字符串全解
USER=myUsername; PASSWORD=myPassword; OPTION=3; "
SQL server
本地数据库
Driver={SQL Server};Database=数据库名;Server=数据库服务器名(localhost);UID=用户名(sa);PWD=用户口令;
注:数据库服务器名(local)表示本地数据库
DNS
DSN
"DSN=myDsn; Uid=username; Pwd=; "
File DSN
"FILEDSN=c:\myData.dsn; Uid=username; Pwd=;"
ODBC连接字符串
DSN=已注册的ODBC数据源名称。如果使用DRIVER关键字,则不用DSN;APP=应用程序名(任选的)
远程数据库
"Driver={SQL Server};Server=130.120.110.001;Address=130.120.110.001,1052;etwork=dbmssocn;
Database=pubs;Uid=sa;Pwd=asdasd;"注:Address参数必须为IP地址,而且必须包括端口号,需指定地址、端口号和网络库;
不带数据库容器
“Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDb=指向.dbf文件的物理路径”
Paradox
“Driver={Microsoft Paradox Driver(*.db)};DBQ=指向.db文件的物理路径;DriverID=26”
本地数据库
"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=myDatabase;

数据库连接字符串的处理方法!加密解密连接字符串。

数据库连接字符串的处理方法!加密解密连接字符串。

数据库连接字符串的处理⽅法!加密解密连接字符串。

数据库连接字符串的处理应该是⼀个项⽬⾥最基础的东东了。

(除⾮你的项⽬不涉及到数据库。

)千万不要⼩看他,处理不好也时会给你带来不少的⿇烦的。

连接字符串的内容在这⾥就不讨论了,这⾥主要说⼀下他的存放位置和读取⽅法。

我们要达到的⽬的:⽆论连接字符串如何变化,都不需要修改项⽬!1.把连接字符串写在程序⾥⾯。

⼀般的初级教程⾥会告诉你这么写Dim cn As New SqlClient.SqlConnection("user id=sa;password=sa;server=.;initial catalog=数据库名称")C#SqlClient.SqlConnection cn = new SqlClient.SqlConnection("user id=sa;password=sa;server=.;initial catalog=数据库名称")这么写当然是没有错误,但是当你写了n个页⾯后,有⼀半的页⾯有这样的代码,这时候如果需要改变连接字符串(⽐如换⽤户名和密码)的话,那可就有得你改的了。

想当初我就犯过这样的错误,5555552.放在web.config⾥⾯这是⽐较流⾏的⽅法了。

修改web.config⽂件,加⼊以下代码<APPSETTINGS><ADD value="user id=sa;password=sa;server=.;initial catalog=数据库名称" key="connString" /></APPSETTINGS>然后在需要的地⽅调⽤就可以了。

Dim cnString As String = System.Configuration.ConfigurationSettings.AppSettings.Item("connString")C#string cnString = System.Configuration.ConfigurationSettings.AppSettings["connString"]这样呢就不怕连接字符串再发⽣变化了。

oracle odbc源代码-概述说明以及解释

oracle odbc源代码-概述说明以及解释

oracle odbc源代码-概述说明以及解释1.引言1.1 概述概述在当今信息化时代,对于数据库管理系统的需求日益增加,Oracle数据库作为一款功能强大、性能稳定的关系型数据库管理系统,受到了广泛的应用和青睐。

而ODBC(Open Database Connectivity)作为一种开放式数据库连接标准,为各种数据库管理系统提供了统一的接口,使得不同数据库之间的数据交互变得更加简便和高效。

本文将对Oracle ODBC源代码进行深入分析,探讨其内部实现原理和关键代码逻辑。

通过对源代码的解读和调试,我们可以深入了解Oracle ODBC的工作原理,进一步优化其性能,提升数据库连接和数据交互的效率。

通过本文的阐述,读者将对Oracle ODBC的实现细节有更为深入的了解,为今后的源代码应用和技术展望提供有力支持。

愿本文能帮助读者更好地理解和应用Oracle ODBC,推动数据库管理系统的发展和进步。

1.2 文章结构文章结构部分包括了本文的整体架构和组织方式。

在本文中,我们将首先介绍Oracle ODBC的简介,包括其基本概念和功能特点。

接着我们将进行ODBC源代码的分析,深入探讨其实现原理和关键代码逻辑。

最后,我们将讨论源代码调试与优化的方法,帮助读者更好地理解和应用Oracle ODBC源代码。

通过这些内容的组织安排,我们旨在为读者提供一份全面且深入的Oracle ODBC源代码解读,帮助他们更好地理解和应用该技术。

1.3 目的本文的目的主要有两个方面:首先,通过对Oracle ODBC源代码的分析,深入了解其内部结构与实现原理,从而提升读者对ODBC驱动的理解和掌握。

通过分析源代码,可以了解Oracle ODBC驱动是如何与Oracle数据库进行交互的,以及其在数据库连接、数据查询等方面的具体实现细节,为读者提供深入学习和探讨的基础。

其次,借助本文探讨源代码调试与优化的部分,帮助读者更好地理解调试技巧和优化方法。

连接字符串汇总

连接字符串汇总

(一)常用连接:1.使用SqlConnection对象:public void SqlConnectionOpen(){SqlConnection conn= new SqlConnection();conn.ConnectionString = "user id=sa;password=;initial catalog=northwind;datasource=localhost;c onnect Timeout=20";conn.Open();}2.使用OleDbConnection对象:public void OleDBConnectionOpen(){OleDBConnection conn = new OleDbconnection();conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Customer.mdb"; conn.Open();}(二) ODBC连接1.ODBC连接Access本地数据库conGoodDay.Open("Driver={Microsoft Access Driver(*.mdb)};"+"Dbq=C:\a.mdb;"+"Uid=Admin;"+"Pwd=;");2.ODBC连接Access系统数据库conGoodDay.Open("Driver={Microsoft Access Driver(*.mdb)};"+"Dbq=C:\a.mdb;"+ "SystemDB=Admin;"+"Pwd=;");3.ODBC连接Access系统数据库conGoodDay.Open("Driver={Microsoft Access Driver(*.mdb)};"+"Dbq=\\server\share\a.mdb;");4.ODBC连接Excel系统数据库conGoodDay.Open("Driver={Microsoft Access Driver(*.xls)};"+"DriverId=790;"+"Dbq=C:\a.xls;"+"DefaultDir=c:\somepath;");5.ODBC连接Oracle系统数据库conGoodDay.Open("Driver={Microsoft ODBC for oracle};"+"Server=OracleServer.world;"+ "Uid=Admin;"+"Pwd=password;");6.ODBC连接Sql ServrconGoodDay.Open("Driver={Sql Server};"+"Server=myServer;"+"Database=myDatabaseName;" "Uid=Admin;"+"Pwd=password;");7.ODBC连接Visual FoxProconGoodDay.Open("Driver={Microsoft Visual FoxPro Driver};"+"SourceType=DBC;"+"SourceDB=c:a.dbc;"+"Exclusive=No;");(三)access连接汇总OLE DB, OleDbConnection (.NET)Standard security:"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password =;"With password:"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database P assword=MyDbPassword;"(四)AccessODBCStandard 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;"(五)ODBC Driver for OracleFor the current Oracle ODBC Driver from Microsoft:oConn.Open "Driver={Microsoft ODBC for Oracle};" & _"Server=OracleServer.world;" & _"Uid=myUsername;" & _"Pwd=myPassword;"For the older Oracle ODBC Driver from Microsoft:oConn.Open "Driver={Microsoft ODBC Driver for Oracle};" & _"ConnectString=OracleServer.world;" & _"Uid=myUsername;" & _"Pwd=myPassword;"OLE DB Provider for Oracle (from Microsoft)oConn.Open "Provider=msdaora;" & _"Data Source=MyOracleDB;" & _"User Id=myUsername;" & _"Password=myPassword;"For more information, see: Microsoft OLE DB Provider for Oracle OLE DB Provider for Oracle (from Oracle)For Standard Security:oConn.Open "Provider=OraOLEDB.Oracle;" & _"Data Source=MyOracleDB;" & _"User Id=myUsername;" & _"Password=myPassword;"For a Trusted Connection:oConn.Open "Provider=OraOLEDB.Oracle;" & _"Data Source=MyOracleDB;" & _"User Id=/;" & _"Password=;"' OroConn.Open "Provider=OraOLEDB.Oracle;" & _"Data Source=MyOracleDB;" & _"OSAuthent=1;"。

odbc connection string

odbc connection string

odbc connection stringODBC(Open Database Connectivity)是一种标准接口,用于在不同的操作系统和编程语言之间建立数据库连接并进行数据交互。

ODBC连接字符串是一串包含数据库连接信息的文本,用于指定如何连接到数据库以及连接的附加选项。

在ODBC连接字符串中,通常包含以下关键组成部分:1. 数据源名称(Data Source Name,DSN):DSN是一个定义在操作系统中的数据源,可以是一个预定义的系统数据源或用户定义的数据源。

DSN可以提供关于要连接的数据库的详细信息,包括数据库类型和位置等。

在连接字符串中指定DSN是一种简单方便的方式来连接数据库。

2. 连接驱动程序(Driver):驱动程序是用于连接数据库的软件组件,ODBC驱动程序可以针对不同的数据库类型进行开发。

在连接字符串中指定驱动程序可以告诉ODBC系统使用哪个驱动程序来建立连接。

3. 连接选项(Options):连接选项是一些可选的参数,用于设置连接的其他细节。

例如,可以设置连接超时时间、字符编码方式、连接池大小等。

下面是一个示例的ODBC连接字符串的格式:Driver={驱动程序名称}; Server={服务器名称或IP地址}; Database={数据库名称}; UID={用户名}; PWD={密码};Option1={选项1的值}; Option2={选项2的值};其中,Driver是必需的, 可以在系统中安装的ODBC驱动程序的列表中找到合适的。

Server指定数据库服务器的名称或IP地址,Database指定要连接的数据库的名称。

UID和PWD分别指定要使用的用户名和密码,用于认证连接。

除了上述基本的连接信息外,还可以在连接字符串中设置其他选项。

例如,可以指定连接超时时间、字符编码方式、连接池大小、只读模式等。

具体可以查询ODBC驱动程序的文档以了解所有可用的选项。

在实际应用中,ODBC连接字符串的内容和格式可能略有不同,具体取决于数据库服务器和驱动程序的要求。

ODBC和OleDb访问数据库的连接字符串

ODBC和OleDb访问数据库的连接字符串

C# 中ODBC和OleDb访问数据库的连接字符串因为工作需要自学数据库的访问,查看相关书籍时,都是以OleDb类进行.Net开发为例,虽然也提到ODBC和OleDb在原理上是一样,但是没有实际的例子,而我恰恰需要通过ODBC来访问数据库,这就碰到连接字符串问题,下面介绍一种简单的查找连接字符串的方法,前提是你用的是VisualStudio开发工具。

步骤一:先在控制面板的数据源ODBC中设定好系统DSN,方法如下;打开“控制面板”—>“管理工具”—>“数据源(ODBC)”,打开“ODBC 数据源管理器”,设置系统DSN或用户DSN。

单击“添加”按钮进入创建新数据源,选择数据源的驱动程序,因为我要演示的是通过ODBC访问本地Access数据库,所以此处选择“Microsoft for Access Driver(*mdb,*accdb)”,其中mdb文件的Access是Access2003数据库文件的后缀,accdb文件Access2007和以上版本数据库文件的后缀,accdb文件转换为mdb需要在Office2007中打开accdb文件然后另存为Access2003数据库,后缀名自动变为mdb,这两种格式的文件数据库连接组件不一样。

当然你也可以通过ODBC访问SQL Serve等其他数据库,虽然使用ODBC能以统一的方式处理所有的数据库,但是使用ODBC来进行.NET开发的时候,其速度要比OleDB、SQL Server慢很多。

选择数据源的驱动程序后自动跳入下面界面,“数据源名”自己设定,此处命名为DataBase,在“数据库”中点击“选择”,选择需要通过ODBC连接的数据库,选择好后在“数据库:”右侧会显示数据库的路径如图。

单击“确定”后返回“ODBC数据源管理器”,此时在系统数据源中已经添加了一个名称为“DataBase”的“Microsoft for Access Driver(*mdb,*accdb)”的驱动程序。

数据库连接字符串大全

数据库连接字符串大全
特殊的TCP/IP端口连接
Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=;Database=myDataBase; User=myUsername;Password=myPassword;
说明:此Driver的默认端口是3306。如果没有在连接字符串中特别指出就是连接Mysql的3306端口。
SevenObjects MySqlClient (.NET)连接方式
标准连接
Host=myServerAddress;UserName=myUsername;Password=myPassword;Database=myDataBase;
Core Labs MySQLDirect (.NET)连接方式
特殊字符集的连接
这个语句指出以使种字符串编码发送到服务器上的查询语句。
以下是语法格式:
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;CharSet=UTF8;
注意:查询结果仍然是以反回数据的格式传送。
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Ignore Prepare=true;
此选项被加入到Connector/NET的5.0.3版和1.0.9版。
特殊的TCP/IP端口连接
-----------excel----------
ODBC 方式
以下是代码片段:
Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDir=c:\mypath;

数据库连接-连接字符串

数据库连接-连接字符串

一.数据库的连接字符串string connectionstr = "Data Source=PC201305072142\\SQLEXPRESS;Da taBase=db_stu;User ID=sa;pwd=123456";Data Source后加你的连接服务器,DataBase后加连接的数据库ID=sa;pwd=123456ID:用户名Pwd:密码二.C#语言实现SQL SERVER、access连接SQL SERVER:添加 using System.Data.SqlClient;SqlConnection con =new SqlConnection("server=.;database=数据库名;uid=sa;pwd=密码");//密码是你数据库sa的登录的密码或者是 SqlConnection con = new SqlConnection("Data source=你的数据库服务器;Initial Catalog=要连接的数据库名;trusetd_connection=sspi");//c是window身份认证的方式access:添加using System.Data.OleDb;OleDbConnection omd=newOleDbConnection("Provider=Microsoft.jet.oldb.4.0;database=数据库的相对路径");//路径是想对你程序运行的路径三.问:如何手动设置数据库连接(数据库的IP、登录密码、用户名称以让用户自己输入一次,然后把它们保存到配置文件中,以后就不需要再输了,直接从配置文件中读取就行了)答:1、在解决方案中添加一个新的类,命名CL_Conn,用于连接数据库。

完整代码如下:using System;using System.Collections.Generic;using ponentModel;using System.Text;using System.Windows.Forms;using Microsoft.Data.ConnectionUI;namespace CL_Conn{public class Conn{/// <summary>/// 获取 自带的数据库连接对话框的数据库连接信息/// </summary>/// <returns>数据库连接</returns>public string GetDatabaseConnectionString(){string connString = String.Empty;Microsoft.Data.ConnectionUI.DataConnectionDialog connDialog = new Microsoft.Data.ConnectionUI.DataConnectionDialog();// 添加数据源列表,可以向窗口中添加自己程序所需要的数据源类型必须增加以下几项中任一一项connDialog.DataSources.Add(Microsoft.Data.ConnectionUI.DataSource.AccessDataSo urce); // AccessconnDialog.DataSources.Add(Microsoft.Data.ConnectionUI.DataSource.OdbcDataSou rce); // ODBCconnDialog.DataSources.Add(Microsoft.Data.ConnectionUI.DataSource.OracleDataSo urce); // OracleconnDialog.DataSources.Add(Microsoft.Data.ConnectionUI.DataSource.SqlDataSourc e); // Sql ServerconnDialog.DataSources.Add(Microsoft.Data.ConnectionUI.DataSource.SqlFileDataSo urce); // Sql Server File// 初始化connDialog.SelectedDataSource =Microsoft.Data.ConnectionUI.DataSource.SqlDataSource;connDialog.SelectedDataProvider =Microsoft.Data.ConnectionUI.DataProvider.SqlDataProvider;//只能够通过DataConnectionDialog类的静态方法Show出对话框//不同使用dialog.Show()或dialog.ShowDialog()来呈现对话框if(Microsoft.Data.ConnectionUI.DataConnectionDialog.Show(connDialog) == DialogResult.OK){connString = connDialog.ConnectionString;}return connString;}}}2、编译。

数据库连接字符串

数据库连接字符串

数据库连接字符串总结标签: 数据库连接字符串一、使用OleDbConnection对象连接OLE DB数据源1.连接Access 数据库Access 2000:“provider=Microsoft.Jet.Oledb.3.5;Data Source=Access文件路径”Access 2003:“provider=Microsoft.Jet.Oledb.4.0;Data Source=Access文件路径”Access 2007:“provider=Microsoft.Ace.Oledb.12.0;Data Source=Access文件路径”备注:Access数据库只提供两个连接属性provider(数据提供程序)和data source(数据源);Access2000\2003的文件格式是“.mdb”,,Access2007的文件格式是“.accdb”; Access的数据提供程序版本是向下兼容的,在Win7下测试使用Microsoft.Jet.OLEDB.3.5提示“未在本地计算机上注册“Microsoft.Jet.OLEDB.3.5”提供程序。

”,改用Microsoft.Jet.OLEDB.4.0或者Microsoft.Ace.OLEDB12.0完全可以访问Access2000的数据库文件。

当然也可以尝试使用微软提供的MDAC 来修改provider的版本。

2.连接Excel数据库Excel 2003:“provider=Microsoft.Jet.OLEDB.4.0;Data Source=Access文件路径;extended properties=excel 8.0”Excel 2007:“provider=Microsoft.Ace.OLEDB.12.0;Data Source=Access文件路径;extended prop erties=excel 12.0”备注:在代码中引用工作表时,应将表名表示为“[工作表名$]”,遇到字段为数据库保留关键字时,给该字段名加上[]以示区别,如定义select 语句时:string connStr=”select * from [login$] where username=’abc’ and [password]=’abc123’ ”;如果在数据表中用数字作为文本类型数据时,则应在数字前加单引号将默认的数值强行设定为文本类型。

数据库链接字符串大全

数据库链接字符串大全

数据库链接字符串⼤全IBM .Net Data Provider您需要使⽤ IBM.Data.DB2.iSeries 命名空间DataSource=myServerAddress;UserID=myUsername; Password=myPassword;DataCompression=True;OLE DB, OleDbConnection (.NET)IBM Client Access OLE DB 适配器Provider=IBMDA400;Data Source=MY_SYSTEM_NAME;User Id=myUsername; Password=myPassword;MY_SYSTEM_NAME是在OperationsNavigator中的系统连接名称。

IBM Client Access OLE DB 适配器Provider=IBMDA400;Data Source=MY_SYSTEM_NAME;User Id=myUsername; Password=myPassword;DefaultCollection=MY_LIBRARY;MY_SYSTEM_NAME是系统连接的名称,MY_LIBRARY是iSeries Navigator中library的名称。

ODBCIBM Client Access ODBC 驱动Driver={Client Access ODBC Driver (32-bit)};System=my_system_name; Uid=myUsername; Pwd=myPassword;IBM iSeries Access ODBC 驱动这个驱动需要⽐IBM Client Access ODBC的驱动更新。

Driver={iSeries Access ODBC Driver};System=my_system_name; Uid=myUsername; Pwd=myPassword;CachéODBC标准DRIVER={InterSystems ODBC};SERVER=myServerAddress; DATABASE=myDataBase; UID=myUsername;PWD=myPassword; 特定端⼝DRIVER={InterSystems ODBC};SERVER=myServerAddress;PORT=12345; DATABASE=myDataBase;UID=myUsername;PWD=myPassword;特定协议DRIVER={InterSystems ODBC};SERVER=myServerAddress;PORT=12345; DATABASE=myDataBase; PROTOCOL=TCP;STATIC CURSORS=1;UID=myUsername;PWD=myPassword;IBM DB2OLE DB, OleDbConnection (.NET)TCP/IPProvider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=XXX.XXX.XXX.XXX; Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=myUsername; Password=myPassword;APPCProvider=DB2OLEDB;APPC Local LU Alias=MyAlias;APPC Remote LU Alias=MyRemote; Initial Catalog=MyCtlg;Package Collection=MyPkgCol; Default Schema=Schema;User ID=myUsername;Password=myPassword;IBM提供的OLE DB适配器TCP/IPProvider=IBMDADB2;Database=myDataBase; Hostname=myServerAddress; Protocol=TCPIP;Port=50000;Uid=myUsername;Pwd=myPassword;ODBC标准Driver={IBM DB2 ODBC DRIVER}; Database=myDataBase;Hostname=myServerAddress;Port=1234;Protocol=TCPIP;Uid=myUsername;Pwd=myPassword;FirebirdODBC - IBPhoenix Open Source标准Driver=Firebird/InterBase(r) driver;Uid=SYSDBA; Pwd=masterkey; DbName=D:\FIREBIRD\examples\TEST.FDB;.NET - Firebird .Net Data Provider标准User=SYSDBA;Password=masterkey;Database=SampleDatabase.fdb; DataSource=localhost;Port=3050;Dialect=3;Charset=NONE;Role=; Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0; InformixODBCInformix 3.30Dsn=;Driver={INFORMIX 3.30 32 BIT};Host=hostname;Server=myServerAddress; Service=service-name; Protocol=olsoctcp; Database=myDataBase;Uid=myUsername;Pwd=myPassword;Informix-CLI 2.5:Driver={Informix-CLI 2.5 (32 Bit)};Server=myServerAddress; Database=myDataBase; Uid=myUsername;Pwd=myPassword;OLE DBIBM Informix OLE DB ProviderProvider=Ifxoledbc.2;Password=myPassword; User ID=myUsername; Data Source=dbName@serverName;Persist Security Info=true; IBM Informix .NET Providerrmix.IfxConnection(命名空间)Database=myDataBase;Host=192.168.10.10; Server=db_engine_tcp; Service=1492;Protocol=onsoctcp;UID=myUsername;Password=myPassword;IngresODBCDSN-lessProvider=MSDASQL.1;DRIVER=Ingres;SRVR=xxxxx;DB=xxxxx;Persist SecurityInfo=False;Uid=myUsername;Pwd=myPassword; SELECTLOOPS=N; ExtendedProperties="SERVER=xxxxx;DATABASE=xxxxx;SERVERTYPE=INGRES";InterbaseODBC, Easysoft本地计算机Driver={Easysoft IB6 ODBC}; Server=localhost ;Database=localhost:C:\mydatabase.gdb; Uid=myUsername; Pwd=myPassword;远程计算机Driver={Easysoft IB6 ODBC}; Server=myServerAddress; Database=ComputerName: C:\mydatabase.gdb;Uid=myUsername;Pwd=myPassword;ODBC, Intersolv本地计算机Driver={INTERSOLV InterBase ODBC Driver (*.gdb)}; Server=localhost; Database=localhost: C:\mydatabase.gdb; Uid=myUsername; Pwd=myPassword;远程计算机Driver={INTERSOLV InterBase ODBC Driver (*.gdb)}; Server=myServerAddress; Database=ComputerName:C:\mydatabase.gdb;Uid=myUsername; Pwd=myPassword;OLE DB, SIBPROvider标准provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb; user id=SYSDBA; Password=masterkey;版本 2.xProvider=SIBPROvider.2; Data Source=localhost:c:\databases\gdbs\mygdb.gdb; Persist Security Info=False;指定字符集provider=sibprovider;location=localhost:;data source=c:\databases\gdbs\mygdb.gdb; user id=SYSDBA; Password=masterkey; character set=ISO8859_1;指定⾓⾊provider=sibprovider;location=localhost:; data source=c:\databases\gdbs\mygdb.gdb;user id=SYSDBA; Password=masterkey;role=DIGITADORES;Lightbase标准连接标准User=myUsername;Password=myPassword;UDB=USERBASE;Server=myServerAddress;MySQLMyODBCMyODBC 2.50 本地数据库Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;MyODBC 2.50 远程数据库Driver={mySQL}; Server=myServerAddress;Port=3306; Option=131072;Stmt=; Database=myDataBase; Uid=myUsername;Pwd=myPassword;MyODBC 3.51 本地数据库Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3; MyODBC 3.51 远程数据库Driver={MySQL ODBC 3.51 Driver};Server=;Port=3306; Database=myDataBase; User=myUsername;Password=myPassword;Option=3;OLE DB, OleDbConnection (.NET)标准Provider=MySQLProv; Data Source=mydb; User Id=myUsername; Password=myPassword;Connector/Net 1.0 (.NET)标准Server=myServerAddress; Database=myDataBase; Uid=myUsername;Pwd=myPassword;默认端⼝号是3306指定端⼝号Server=myServerAddress; Port=1234;Database=myDataBase; Uid=myUsername; Pwd=myPassword;命名管道Server=myServerAddress; Port=-1;Database=myDataBase; Uid=myUsername;Pwd=myPassword;如果端⼝是-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")=adPromptAlways oConn.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")=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;"-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;IntegratedSecurity=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();:Imports System.Data.SqlClient Dim oSQLConn As SqlConnection=New SqlConnection()oSQLConn.ConnectionString="my connection string"oSQLConn.Open()Data Shape MS Data Shape"Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=Aron1;Initial Catalog=pubs;User ID=sa;Password=asdasd;"Want to learn data shaping?Check out 4GuyfFromRolla's greatarticle about Data Shaping Read more How to define which 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;"Name Network library dbnmpntw Win32 Named Pipes dbmssocn Win32 Winsock TCP/IP dbmsspxn Win32 SPX/IPX dbmsvinn Win32 Banyan Vines dbmsrpcn Win32 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 connection string properties This table shows all connection string properties for the SqlConnection object.Most of the properties are also used in ADO.All properties and descriptions is from msdn.Name Default Description application 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 Timeout 15 The length of time(in seconds)to wait for aconnection to the server before terminating the attempt and generating an error.Connection Lifetime 0When aconnection is returned to the pool,its creation time is com pared with the current time,and the connection is destroyed if that time span(in seconds)exceeds the value specified by connection eful in clustered configurations to force load balancing between arunning server and aserver 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 aconnection,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 asecure connection or not.Recognized values are'true','false',and'sspi',which is equivalent to'true'.Max Pool Size 100 The maximum number of connections allowed in the pool.Min Pool Size 0The minimum number of connections allowed in the pool.Network Library-or-Net'dbmssocn'The network library used to establish aconnection to an instance of SQL Server.Supported values include dbnmpntw(Named Pipes),dbmsrpcn(Multiprotocol),dbmsadsn(AppleTalk),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 anetwork and you use alocal server(for example,"."or"(local)"),shared memory is used.Packet Size 8192 Size 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 inf ormation,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 ID the local computer name The name of the workstation connecting to SQL Server.Note Use;to separate each property.If aname occurs more than once,the value from the last one in the connection string will be used.If you are building your connection string in your app using values from user input fields,make sure the user can't change the connection string by inserting an additional property with another value within the user value.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;"Equivalents Integrated Security=SSPI equalsTrusted_Connection=yes Prompt for username and password:oConn.Properties("Prompt")=adPromptAlways oConn.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"Equivalents MultipleActiveResultSets=true equalsMARS_Connection=yes Using MARS with SQL Native Client,by Chris Lee Encrypt data sent over network:"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;Encrypt=yes"Attach adatabase file on connect to alocal 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=|DataDirectory|mydbfile.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).Download the SQL Native Client here(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 equalsTrusted_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 Using MARS with SQL Native Client,by Chris Lee Encrypt data sent over network:"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;Encrypt=yes"Attach adatabase file on connect to alocal 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=|DataDirectory|mydbfile.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).Download the SQL Native Client here(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;IntegratedSecurity=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 2.0 for MARS functionality.MARS is not supported in 1.0 nor 1.1 Streamline your Data Connections by Moving to MARS,by Laurence Moroney, Attach adatabase file on connect to alocal SQL Server Express instance:"Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Database=dbname;Trusted_Connection=Yes;"-or-"Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.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 alocal SQL Server Express instance:"Data Source=.\SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|\mydb.mdf;user instance=true;"The"User Instance"functionality creates anew SQL Server instance on the fly during connect.This works only on alocal SQL Server 2005 instance and only when connecting using windows authentication over local named pipes.The purpose is to be able to create afull rights SQL Server instance to auser 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.Read more When to use SQL Native Client?.Net applications Do not use the SQL Native e Framework Data Provider for SQL Server(SqlConnection).COM applications,all other applications Use the SQL Native Client if you are accessing an SQL Server 2005 and need the new features of SQL Server 2005 such as MARS,encryption,xml data type etc.Continue use your current provider(OLE DB/ODBC through the MDAC package)if you are not connecting to an SQL Server 2005(that's quite obvious eh.)or if you are connecting to an SQL Server 2005 but arenot using any of the new SQL Server 2005 features.For more details on the differences between MDAC and SQL Native Client,read this msdn article Access ODBC Standard 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;"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;"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;UserId=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 3or later Specifying username and password:"Data Source=MyOracleDB;User Id=username;Password=passwd;Integrated Security=no;"This one works only with Oracle 8i release 3or later Declare the OracleConnection:C#:using System.Data.OracleClient;OracleConnection oOracleConn=new OracleConnection();oOracleConn.ConnectionString="my connection string";oOracleConn.Open();:Imports System.Data.OracleClient Dim oOracleConn As OracleConnection=New OracleConnection()oOracleConn.ConnectionString="my connection string"oOracleConn.Open()Missing the System.Data.OracleClient namespace? Managed Provider for Oracle Great article!"Features of Oracle Data Provider "by Rama Mohan G.at C#Corner Core Labs OraDirect(.NET)"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 Shape MS Data Shape:"Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw"Want to learn data shaping?Check out 4GuyfFromRolla's greatarticle about Data Shaping MySQL MyODBC MyODBC 2.50 Local database:"Driver={mySQL};Server=localhost;Option=16834;Database=mydatabase;"MyODBC 2.50 Remote database:"Driver={mySQL};Server=;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=;PORT=3306;DATABASE=myDatabase;USER=myUsername;PASSWORD=myPassword;OPTION=3;"OLE DB,OleDbConnection(.NET)"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 anamed 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();: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 Declare the MySqlConnection:C#:using eInfoDesigns.dbProvider.MySqlClient;MySqlConnection oMySqlConn=new MySqlConnection();oMySqlConn.ConnectionString="my connection string";oMySqlConn.Open();: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 afreeware 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;ConnectionLifetime=0"Read more at Core Lab and the product page.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"Read more about this driver:Easysoft ODBC-Interbase driver ODBC,Intersolv Local 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,SIBPROvider Standard:"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"Read more about SIBPROvider Read more about connecting to Interbase in this Borland Developer Network article IBM DB2 OLE DB,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"IBM's OLE DB Provider(shipped with IBM DB2 UDB v7 or above)TCP/IP:Provider=IBMDADB2;Database=sample;HOSTNAME=db2host;PROTOCOL=TCPIP;PORT=50000;uid=myUserName;pwd=myPwd;ODBC Standard:"driver={IBM DB2 ODBC DRIVER};Database=myDbName;hostname=myServerName;port=myPortNum;protocol=TCPIP;uid=myUserName;pwd=myPwd"Sybase ODBC Standard Sybase System 12(or 12.5)Enterprise Open Client:"Driver={SYBASE ASE ODBC Driver};Srvr=Aron1;Uid=username;Pwd=password"Standard Sybase System 11:"Driver={SYBASE SYSTEM 11};Srvr=Aron1;Uid=username;Pwd=password;Database=mydb"For more information check out the Adaptive Server Enterprise Document Sets Intersolv 3.10:"Driver={INTERSOLV 3.10 32-BIT Sybase};Srvr=Aron1;Uid=username;Pwd=password;"Sybase SQL Anywhere(former Watcom SQL ODBC driver):"ODBC;Driver=Sybase SQL Anywhere 5.0;DefaultDir=c:\dbfolder\;Dbf=c:\mydatabase.db;Uid=username;Pwd=password;Dsn="""""Note!The two double quota following the DSN parameter at the end are escaped quotas(VB syntax),you may have to change this to your language specific escape syntax.The empty DSN parameter is indeed critical as not including it will result in error 7778.Read more in the Sybase SQL Anywhere User Guide(see part3,chapter 13)OLE DB Adaptive Server Anywhere(ASA):"Provider=ASAProv;Data source=myASA"Read more in the ASA User Guide(part 1,chapter 2)Adaptive Server Enterprise(ASE)with Data Source.IDS file:"Provider=Sybase ASE OLE DB Provider;Data source=myASE"Note that you must create aData Source.IDS file using the Sybase Data Administrator.These.IDS files resemble ODBC DSNs.Adaptive Server Enterprise(ASE):"Provider=Sybase.ASEOLEDBProvider;Srvr=myASEserver,5000;Catalog=myDBname;User Id=username;Password=password"-some reports on problem using the above one,try the following as an alternative-"Provider=Sybase.ASEOLEDBProvider;Server Name=myASEserver,5000;Initial Catalog=myDBname;User Id=username;Password=password"This one works only from Open Client 12.5 where the server port number feature works,?allowing fully qualified connection strings to be used without defining?any.IDS Data Source files.AseConnection(.NET)Standard:"Data Source='myASEserver';Port=5000;Database='myDBname';UID='username';PWD='password';"Declare the AseConnection:C#:using Sybase.Data.AseClient;AseConnection oCon=new AseConnection();oCon.ConnectionString="my connection string";oCon.Open();:Imports System.Data.AseClient Dim oCon As AseConnection=New AseConnection()oCon.ConnectionString="my connection string"oCon.Open()Read more!Adaptive Server Enterprise Data Provider Documentation 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"OLE DB IBM Informix OLE DB Provider:"Provider=Ifxoledbc.2;password=myPw;User ID=myUser;Data[email=Source=dbName@serverName;Persist]Source=dbName@serverName;Persist[/email]Security Info=true"Ingres ODBC DSN-less"Provider=MSDASQL.1;DRIVER=Ingres;SRVR=xxxxx;DB=xxxxx;Persist Security Info=False;uid=xxxx;pwd=xxxxx;SELECTLOOPS=N;Extended Properties="""SERVER=xxxxx;DATABASE=xxxxx;SERVERTYPE=INGRES""Mimer SQL ODBC Standard Security:"Driver={MIMER};Database=mydb;Uid=myuser;Pwd=mypw;"Prompt for username and password:"Driver={MIMER};Database=mydb;"Lightbase Standard Standard:"user=USERLOGIN;password=PASSWORD;UDB=USERBASE;server=SERVERNAME"PostgreSQL Core Labs PostgreSQLDirect(.NET)Standard:"User ID=root;Password=pwd;Host=localhost;Port=5432;Database=testdb;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0"Read more at Core Lab and the product page.PostgreSQL driver Standard:"DRIVER={PostgreSQL};SERVER=ipaddress;port=5432;DATABASE=dbname;UID=username;PWD=password;"Npgsql by pgFoundry(.NET)SSL activated:"Server=127.0.0.1;Port=5432;Userid=myuserid;password=mypw;Protocol=3;SSL=true;Pooling=true;MinPoolSize=3;MaxPoolSize=20;Encoding=UNICODE;Timeout=20;SslMode=Require"Without SSL:"Server=127.0.0.1;Port=5432;Userid=myuserid;password=mypw;Protocol=3;SSL=false;Pooling=true;MinPoolSize=1;MaxPoolSize=20;Encoding=UNICODE;Timeout=15;SslMode=Disable"Read more in the Npgsql:User's Manual and on the pgFoundry website.Paradox ODBC 5.X:Driver={Microsoft Paradox Driver(*.db)};DriverID=538;Fil=Paradox 5.X;DefaultDir=c:\pathToDb\;Dbq=c:\pathToDb\;CollatingSequence=ASCII"7.X:"Provider=MSDASQL.1;Persist Security Info=False;Mode=Read;Extended Properties='DSN=Paradox;DBQ=C:\myDb;DefaultDir=C:\myDb;DriverId=538;FIL=Paradox 7.X;MaxBufferSize=2048;PageTimeout=600;';Initial Catalog=C:\myDb"OleDbConnection(.NET)Standard"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\myDb;Extended Properties=Paradox 5.x;"MS kb-article:How to use Paradox data with Access and Jet DSN ODBC DSN:"DSN=myDsn;Uid=username;Pwd=;"File DSN:"FILEDSN=c:\myData.dsn;Uid=username;Pwd=;"Firebird ODBC-IBPhoenix Open Source Standard:"DRIVER=Firebird/InterBase(r)driver;UID=SYSDBA;PWD=masterkey;DBNAME=D:\FIREBIRD\examples\TEST.FDB"IBPhoenix ODBC;More info,download etc Data Provider Standard:"User=SYSDBA;Password=masterkey;Database=SampleDatabase.fdb;DataSource=localhost;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0"。

深入分析C#连接Oracle数据库的连接字符串详解

深入分析C#连接Oracle数据库的连接字符串详解

深⼊分析C#连接Oracle数据库的连接字符串详解1..IP+SID⽅式复制代码代码如下:DbHelperOracle.connectionString = string.Format(@"Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = 1521)))(CONNECT_DATA =(SID = {1})(SERVER = DEDICATED)));User Id={2};Password={3};",txtDBServerIP.Text.Trim(), txtOracleSID.Text.Trim(), txtDBUserName.Text.Trim(), txtDBPassword.Text.Trim());这种⽅式不需要在Oracle Net Manager管理中添加链接配置信息。

2. 2.配置链接⽅式,在Oracle Net Manager管理中添加链接配置信息,然后链接字符串如下写法:复制代码代码如下:Data Source=TORCL;User Id=myUsername;Password=myPassword;另外其他的连接⽅式,参考如下,从其他⽹站转来的:Oracle XE(或者"Oracle Database 10g Express Edition")是⼀个简单免费发布的版本。

以下是语法格式:复制代码代码如下:Driver=(Oracle in XEClient);dbq=111.21.31.99:1521/XE;Uid=myUsername;Pwd=myPassword;ODBC复制代码代码如下:Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword;复制代码代码如下:Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword OLE DB, OleDbConnection (.NET)复制代码代码如下:Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;复制代码代码如下:Provider=msdaora;Data Source=MyOracleDB;Persist Security Info=False;Integrated Security=Yes;复制代码代码如下:Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;复制代码代码如下:Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;以下是语法格式:复制代码代码如下:Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS= (PROTOCOL=TCP)(HOST=myHost)(PORT=myPort)))(CONNECT_DATA=(SID=MyOracleSID)(SERVER=DEDICATED)));User Id=myUsername;Password=myPassword;Oracle.DataAccess.Client.OracleConnection复制代码代码如下:Data Source=TORCL;User Id=myUsername;Password=myPassword;复制代码代码如下:Data Source=TORCL;Integrated Security=SSPI;复制代码代码如下:Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))) (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));UserId=myUsername;Password=myPassword;OracleConnection, Oracle Data Provider, , System.Data.OracleClient.OracleConnection复制代码代码如下:Data Source=MyOracleDB;Integrated Security=yes复制代码代码如下:Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;这是另⼀种连接⽅式不依赖你的DNS.You create a connection string based on the format used in the tnsnames.ora file without the need to actually have one of these files on the client pc.以下是语法格式:复制代码代码如下:SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA= (SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;Some reported problems with the one above and Visual Studio. Use the next one if you've encountered problems.以下是语法格式:复制代码代码如下:Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA= (SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;连接池服务如果找不到⼀个完全匹配连接字符串的连接,他将会创建⼀个。

数据库连接字符串详解

数据库连接字符串详解

SQLserver:命名空间应用:using System.Data;using System.Data.SqlClient;字符串:@"Server=服务器名;Database=数据库名;User ID=用户名;Password=密码;" window身份验证字符串写法:@"Data Source=.;Initial Catalog=数据库名;Integrated Security=True"SQL身份验证:字符串写法 @"server=.;database=ReportServer;uid=sa;pwd=sa"access:命名空间应用:using System.Data;using System.Data.OleDb;字符串:@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库的物理路径;User ID=用户名;Password=你的密码;"无密码字符串:@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库的物理路径;"注解:1. “@”符号用于防止将后面字符串中的“\”解析为转义字符。

也就是回车“\n”2. (local)表示本地3. Application.StartupPath相对路径可添加属性:(在字符串中可以添加的属性,用";"符号分开即可)1. Persist Security Info=false/true 在数据库连接成功后是否保存密码信息,True表示保存,False表示不保存中默认情况下为false2. Connect Timeout=分钟数设定多少分钟之后过期附录:1关键字其中一些关键字及其值的说明:(关键字不区分大小写)1.Connect Timeout表示连接超时的意思,即在终止尝试并产生错误之前,等待与服务器的连接的时间长度(以秒为单位),默认值为15.2.Data Source 或 Server两个关键字都代表同一个意义,即要连接的SQL Server实例的名称或网络地址。

odbc connection string

odbc connection string

ODBC连接字符串介绍•ODBC (Open Database Connectivity) 是一种为计算机上的应用程序提供统一访问数据库的标准接口。

应用程序通过ODBC接口与数据库进行通信,而不需要关心具体数据库的类型或者版本。

•ODBC连接字符串是一种用于建立与数据库的连接的字符串,它包含了一系列参数和选项,用于指定数据库的位置、访问权限和其他配置信息。

ODBC连接字符串的构成•ODBC连接字符串由一系列以分号分隔的键值对组成,每个键值对用于指定特定的连接参数或选项。

常见的连接参数和选项包括:–Driver:用于指定ODBC驱动程序的名称或者路径。

–Server:用于指定数据库服务器的名称或者IP地址。

–Database:用于指定连接的数据库的名称。

–UID和PWD:用于指定连接数据库所使用的用户名和密码。

–Port:用于指定数据库服务器的端口号。

–CharSet:用于指定数据库的字符集。

–Connection Timeout:用于指定连接数据库的超时时间。

–Trusted_Connection:用于指定是否使用Windows身份验证进行连接。

–Encrypt:用于指定是否加密数据库连接。

•不同的ODBC驱动程序和数据库可能支持不同的连接参数和选项,具体的参数和选项需要参考相关的文档或者驱动程序提供商的说明。

ODBC连接字符串的示例•下面是一个示例的ODBC连接字符串:Driver={SQL Server};Server=myServerAddress;Database=myDataBase;UID=myUsername; PWD=myPassword;•上述连接字符串使用了SQL Server的ODBC驱动程序,连接到名为myDataBase的数据库,使用了myUsername和myPassword作为连接的用户名和密码。

连接字符串的写法规则•ODBC连接字符串需要按照一定的写法规则进行构造:–键值对之间使用分号进行分隔。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
独占
"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb; Exclusive=1; Uid=admin; Pwd="
dBase
"Driver={microsoft dbase driver(*.dbf)};driverid=277;dbq=------------;"
USER=myUsername; PASSWORD=myPassword; OPTION=3; "
SQL server
本地数据库
Driver={SQL Server};Database=数据库名;Server=数据库服务器名(localhost);UID=用户名(sa);PWD=用户口令;
注:数据库服务器名(local)表示本地数据库
“Driver={Microsoft Text Driver(*.txt;*.csv)};DefaultDir=指向.txt文件的物理路径”
Visual FoxPro
带数据库容器
“Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDb=指向.dbc文件的物理路径”
Microsoft Excel
Driver={Microsoft Excel Driver(*.xls)};DBQ=指向.xls文件的物理路径;DriverID=278(97版本:ID=790)
MS text
"Driver={microsoft text driver(*.txt; *.csv)};dbq=-----;extensions=asc,csv,tab,txt;Persist SecurityInfo=false;"
数据源驱动器
ODBC连接字符串
access
标准安全
"Driver={microsoft access driver(*.mdb)};dbq=*.mdb(注释:指向文件的物理路径);
uid=admin(uid=f);pwd=pass(pwd =f);
工作组
"Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\mydatabase.mdb; SystemDB=C:\mydatabase.mdw; "
oracle
"Driver={microsoft odbc for oracle};server=oraclesever.world(指向服务器的路径);uid=admin;pwd=pass;"
MSSQL
MyODBC 2.50
本地数据库
"Driver={mySQL}; Server=localhost(本地数据库); Option=16834; Database=mydatabase(所请求的缺省数据库(任选项)); "
不带数据库容器
“Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDb=指向.dbf文件的物理路径”
Paradox
“Driver={Microsoft Paradox Driver(*.db)};DBQ=指向.db文件的物理路径;DriverID=26”
本地数据库
"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=myDatabase;
USER=myUsername; PASSWORD=myPassword; OPTION=3;"
MyODBC 3.51
远程数据库
"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=; PORT=3306; DATABASE=myDatabase;
远程数据库
"Driver={SQL Server};Server=130.120.110.001;Address=130.120.110.001,1052;Network=dbmssocn;
Database=pubs;Uid=sa;Pwd=asdasd;"注:Address参数必须为IP地址,而且必须包括端口号,需指定地址、端口n; Uid=username; Pwd=; "
File DSN
"FILEDSN=c:\myData.dsn; Uid=username; Pwd=;"
ODBC连接字符串
DSN=已注册的ODBC数据源名称。如果使用DRIVER关键字,则不用DSN;APP=应用程序名(任选的)
UDL连接字符串:"File Name=c:\myDataLink.udl;"
MyODBC 2.50
远程数据库
"Driver={mySQL}; Server=; Port=3306; Option=131072;
Stmt=; Database=my-database; Uid=username; Pwd=password;"
MyODBC 3.51
相关文档
最新文档