无DSN(非DSN)连接
除了ADO所定义的参数外,提供者不支持任何特定连接参数,它将把任何非ADO连接参数传递给ODBC驱动程序管理器。下面介绍几种常见数据库的处理方法。
1. Visual Foxpro
[PROVIDER=MSDASQL.1]; ’或者为MSDASQL
DRIVER={Driver Name};
SourceDB=Path;
SourceType=DBF
例如:
cnna.ConnectionString = “PROVIDER=MSDASQL; ”
+ “DRIVER={Microsoft Visual Foxpro Driver};”
+ “SourceDB=D:\data\;”
+ “SourceType=DBF”
2.SQL Server
[PROVIDER=MSDASQL;]
DRIVER={Driver Name};
SERVER=server;
DATABASE=database;
UID=user;
PWD=password
例如:
cnnb.ConnectionString = “PROVIDER=MSDASQL;”
+ “DRIVER={SQL Server};”
+ “SERVER=servera;”
+ “DATABASE=pubs;”
+ “UID=sa;”
+ “PWD=yyuui”
3. Sybase数据库
[PROVIDER=MSDASQL;]
DRIVER={Driver Name};
SRVR=server; ’必须是SRVR,不能是SERVER
DB=database; ’可以是DB,也可以是DATABASE
DSN=; ’可以省略
UID=user;
PWD=passwod;
PERSIST SECURITY INFO=False
例如:
cnnc.ConnectionString=“PROVIDER=MSDASQL;”
+ “DRIVER={Sybase System 11};”
+ “SRVR=serveru; ”
+ “DSN=;”
+ “DB=dataa;”
+ “UID=sa;”
+ “PWD=dqwe;”
+ “PERSIST SECURITY INFO=False”
4. Oracle数据库
[PROVIDER=MSDASQL;]
DRIVER={Driver Name};
SERVER=server;
databasename=database;
databasefile=path;
DSN=;
UID=user;
PWD=password;
例如:
cnnd.ConnectionString = “PROVIDER=MSDASQL; ”
+ “DRIVER={Microsoft ODBC for Oracle};”
+ “SERVER=Webserver;”
+ “DSN=;”
+ “databasename=dataall;”
+ “databasefile=d:\data\;”
+ “UID=dba;”
+ “PWD=killer”