Dim str_sql As String
str_sql = "Exec Pro_DFJS '" & str_CSVfailed & "'," & NowPrice & "," & baojingxianzhi & ",'" & str_sunhaoft1 & "','" & str_bjinclude & "','" & str_gongyongft & "'"
Dim str_jsxx As String
Dim LastDb As New ADODB.Recordset
If Main_conn.State = 0 Then Main_conn.Open
With LastDb
.ActiveConnection = Main_conn
.Source = str_sql
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Execute str_sql
While Not .EOF
'如果是0计算失败
If Len(.Fields("bz")) = "0" Then
fault = Trim(.Fields("falut"))
str_jsxx = Trim(.Fields("nr"))
MsgBox str_jsxx, vbInformation, Mytitle
Call faucolor
End If
'如果是1计算成功
If Len(.Fields("bz")) = "1" Then
str_jsxx = "电费计算成功!"
End If
.MoveNext
Wend
.Close
End With
11 个解决方案
#1
什么数据库?
#2
在存储过程中定义了临时表,执行完成以后,返回临时表的数据,但是在程序中没有到执行就报错;
#3
.Execute str_sql 这一句报错么?
具体报什么错?
具体报什么错?
#4
sql server2000数据库,返回一个错是"实时错误'-2147217871(80040e31)':超时已过期"
#5
把str_sql 的值打出来看看
#6
上面的程序语句有问题,谁能给一个执行存储过程并返回值的代码
#7
Exec Pro_DFJS 'False',1,5,'False','False','False'
获取以后是这样,
.Execute str_sql
改为
set lastDB=MAin_conn.execute(strSql)
获取以后是这样,
.Execute str_sql
改为
set lastDB=MAin_conn.execute(strSql)
#8
sql语句肯定是对的,存储过程已经测试了
#9
Dim str_sql As String
' str_sql = "Exec Pro_DFJS @参数1='" & str_CSVfailed & "',@参数2=" & NowPrice ……
Dim str_jsxx As String
Dim LastDb As New ADODB.Recordset
If Main_conn.State = 0 Then Main_conn.Open
With LastDb
.ActiveConnection = Main_conn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open str_sql
While Not .EOF
'如果是0计算失败
If Len(.Fields("bz")) = "0" Then
fault = Trim(.Fields("falut"))
str_jsxx = Trim(.Fields("nr"))
MsgBox str_jsxx, vbInformation, Mytitle
Call faucolor
End If
'如果是1计算成功
If Len(.Fields("bz")) = "1" Then
str_jsxx = "电费计算成功!"
End If
.MoveNext
Wend
.Close
End With
Set LastDb = Nothing
#10
问题弄好了,谢谢
#11
Dim cmd As New ADODB.Command
Dim LastDb As New ADODB.Recordset
'Build the Command object
With cmd
.ActiveConnection = Main_conn
.CommandText = "Pro_DFJS"
.CommandType = adCmdStoredProc
.Parameters.Refresh
.Parameters("@参数名1") = str_CSVfailed '参数名你自己替换成正确的'
.Parameters("@参数名2") = NowPrice '参数名你自己替换成正确的'
……
.Parameters("@参数名n") = str_gongyongft '参数名你自己替换成正确的'
End With
'Create the Recordset
Set LastDb = cmd.Execute
MsgBox rs.Fields("字段名1") '字段名你自己替换成正确的'
rs.Close
Set rs = Nothing
Set cmd = Nothing
#1
什么数据库?
#2
在存储过程中定义了临时表,执行完成以后,返回临时表的数据,但是在程序中没有到执行就报错;
#3
.Execute str_sql 这一句报错么?
具体报什么错?
具体报什么错?
#4
sql server2000数据库,返回一个错是"实时错误'-2147217871(80040e31)':超时已过期"
#5
把str_sql 的值打出来看看
#6
上面的程序语句有问题,谁能给一个执行存储过程并返回值的代码
#7
Exec Pro_DFJS 'False',1,5,'False','False','False'
获取以后是这样,
.Execute str_sql
改为
set lastDB=MAin_conn.execute(strSql)
获取以后是这样,
.Execute str_sql
改为
set lastDB=MAin_conn.execute(strSql)
#8
sql语句肯定是对的,存储过程已经测试了
#9
Dim str_sql As String
' str_sql = "Exec Pro_DFJS @参数1='" & str_CSVfailed & "',@参数2=" & NowPrice ……
Dim str_jsxx As String
Dim LastDb As New ADODB.Recordset
If Main_conn.State = 0 Then Main_conn.Open
With LastDb
.ActiveConnection = Main_conn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open str_sql
While Not .EOF
'如果是0计算失败
If Len(.Fields("bz")) = "0" Then
fault = Trim(.Fields("falut"))
str_jsxx = Trim(.Fields("nr"))
MsgBox str_jsxx, vbInformation, Mytitle
Call faucolor
End If
'如果是1计算成功
If Len(.Fields("bz")) = "1" Then
str_jsxx = "电费计算成功!"
End If
.MoveNext
Wend
.Close
End With
Set LastDb = Nothing
#10
问题弄好了,谢谢
#11
Dim cmd As New ADODB.Command
Dim LastDb As New ADODB.Recordset
'Build the Command object
With cmd
.ActiveConnection = Main_conn
.CommandText = "Pro_DFJS"
.CommandType = adCmdStoredProc
.Parameters.Refresh
.Parameters("@参数名1") = str_CSVfailed '参数名你自己替换成正确的'
.Parameters("@参数名2") = NowPrice '参数名你自己替换成正确的'
……
.Parameters("@参数名n") = str_gongyongft '参数名你自己替换成正确的'
End With
'Create the Recordset
Set LastDb = cmd.Execute
MsgBox rs.Fields("字段名1") '字段名你自己替换成正确的'
rs.Close
Set rs = Nothing
Set cmd = Nothing