|
代码1:将查询字段设为常量
LoginUserName="吴静"
SupplyExportCodeName="需求09110000149"
Dim con
Dim conset
Dim rs
Dim sql
Dim con2
Dim conset2
Dim rs2
Dim sql2
If (UseCase="代管物资出库") Then
'//建立连接
Set con=createobject("adodb.connection")
conset="MSDASQL.1;Persist Security Info=False;User ID=sa;PWD=1111;Data Source=datasource_gzmmis;Initial Catalog=gzscene"
'//打开数据源链接
con.open conset
'//建立空的记录集
Set rs=createobject("adodb.recordset")
'//设置SQL语句
msgbox SupplyExportCodeName
sql="use gzscene select SupplyExportCode from im_supplyexport where stockapplycode like'%"+SupplyExportCodeName+"%' "
'//打开记录集
rs.open sql,con,1,2
rs.Movefirst
SupplyExportCodeValue=rs("SupplyExportCode").value
msgbox SupplyExportCodeValue
End If
'//建立连接
Set con2=createobject("adodb.connection")
conset2="MSDASQL.1;Persist Security Info=False;User ID=sa;PWD=1111;Data Source=datasource_gzmmis;Initial Catalog=gzscene"
Set rs2=createobject("adodb.recordset")
'//打开数据源链接
con2.open conset2
msgbox "LoginUserName="+LoginUserName
sql2="use gzscene select PWD from S_USER where UNAME like'%"+LoginUserName+"%' "
rs2.open sql2,con,1,2
rs2.Movefirst
LogPwd=rs2("PWD").value
msgbox LogPwd
代码2:将查询字段设为变量,而变量由excel提供
LoginUserName=bsSheet.Cells(2,3)
SupplyExportCodeName=bsSheet.Cells(2,2)
Dim con
Dim conset
Dim rs
Dim sql
Dim con2
Dim conset2
Dim rs2
Dim sql2
If (UseCase="代管物资出库") Then
'//建立连接
Set con=createobject("adodb.connection")
conset="MSDASQL.1;Persist Security Info=False;User ID=sa;PWD=1111;Data Source=datasource_gzmmis;Initial Catalog=gzscene"
'//打开数据源链接
con.open conset
'//建立空的记录集
Set rs=createobject("adodb.recordset")
'//设置SQL语句
msgbox SupplyExportCodeName
sql="use gzscene select SupplyExportCode from im_supplyexport where stockapplycode like'%"+SupplyExportCodeName+"%' "
'//打开记录集
rs.open sql,con,1,2
rs.Movefirst
SupplyExportCodeValue=rs("SupplyExportCode").value
msgbox SupplyExportCodeValue
End If
'//建立连接
Set con2=createobject("adodb.connection")
conset2="MSDASQL.1;Persist Security Info=False;User ID=sa;PWD=1111;Data Source=datasource_gzmmis;Initial Catalog=gzscene"
Set rs2=createobject("adodb.recordset")
'//打开数据源链接
con2.open conset2
msgbox "LoginUserName="+LoginUserName
sql2="use gzscene select PWD from S_USER where UNAME like'%"+LoginUserName+"%' "
rs2.open sql2,con,1,2
rs2.Movefirst
LogPwd=rs2("PWD").value
msgbox LogPwd
问题描述:如果单独执行代码1,是成功的,执行代码2时此时执行到rs2.open sql2,con,1,2的时候就会提示”参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突“,请问我将两个sql即:sql,sql2z放在同一个Action里面该如何处理?
PS:代码2中的两个LoginUserName等是放在excel里面,且存在循环
[ 本帖最后由 walker1020 于 2009-12-1 10:15 编辑 ] |
|