qtp 连接SQL和连接MYSQL 是否一样
qtp 连接SQL和连接MYSQL 是否一样? SQL1.本地没有创建数据源的方式
DRIVER=SQL Server;SERVER=数据库IP地址;UID=用户名;PWD=密码;APP=Microsoft Office 2003;WSID=本地主机名;DATABASE=数据库名
实例:
DRIVER=SQL Server;SERVER=10.160.11.10;UID=sa;PWD=sa;APP=Microsoft Office 2003;WSID=RJHLJUN;DATABASE=dcwork
2.本地已创建数据源的方式
DSN=数据源名称;UID=用户名;PWD=密码;APP=Microsoft Office 2003;WSID=数据库的主机名;DATABASE=数据库名
实例:
DSN=LocalServer;UID=sa;PWD=sa;APP=Microsoft Office 2003;WSID=RJDCWORKTEST;DATABASE=dcwork
3.SQL语句实例(从数据库表HR_LANGUAGE_TYPE中,查询字段语言名称LANGUAGE_NAME,条件语言名称=中文,按语言名称升序排序结果)
source(SQL语句):
SELECT HR_LANGUAGE_TYPE.LANGUAGE_NAMEFROM dcwork.dbo.HR_LANGUAGE_TYPE HR_LANGUAGE_TYPEWHERE (HR_LANGUAGE_TYPE.LANGUAGE_NAME='中文')ORDER BY HR_LANGUAGE_TYPE.LANGUAGE_NAME
MYSQL格式:(本地需要安装MYSQL ODBC DRIVER)
Dim Cnn
Set Cnn = CreateObject("ADODB.Connection")
Cnn.ConnectionString ="DATABASE=testmysql;DSN=192.168.1.63;OPTION=0;PWD=123456;PORT=0;SERVER=192.168.1.63;UID=root"
Cnn.Open
If Cnn.State = 0 Then
Reporter.ReportEvent micFail, "testing", "连接数据库失败"
else
Reporter.ReportEvent micPass, "testing", "连接数据库成功"
end if
2.本地已创建数据源的方式
DSN=数据源名称;UID=用户名;PWD=密码;DBQ=数据库名;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;
实例:
DSN=dcworkoracle;UID=DCWORK;DBQ=DCWORK;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;
3.SQL语句实例
source:SQL语句
SELECT HR_LANGUAGE_TYPE.LANGUAGE_NAMEFROM DCWORK.HR_LANGUAGE_TYPE HR_LANGUAGE_TYPEWHERE (HR_LANGUAGE_TYPE.LANGUAGE_NAME='中文')ORDER BY HR_LANGUAGE_TYPE.LANGUAGE_NAME thanks,study
页:
[1]