我得到一个运行时错误3709 [英] Im getting a runtime error 3709

查看:169
本文介绍了我得到一个运行时错误3709的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Im writting a code which enter values in a table1.. But before checking the values in table2 given in the condition.. Only if the condition is correct the values will be entered in table1. Error 3709 appears near cmd.Execute




Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Dim BrdSrNo As String
Dim Result As Boolean
Dim machineName As String
Dim stage_Id As String
Dim stage_Status As String
Dim cmd As New ADODB.Command
Dim param As ADODB.Parameter
machineName = Environ("computername")
' Ready objects for use.
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
BrdSrNo = BoardSrNo.Text
Result = False
' Connect.
cn.Open "{Ill give my connection string here}"
' Fetch a recordset.
rs.Open "select * from testreport_tb1 where board_SrNo = '" & BrdSrNo & "' order by test_DateTime desc", cn, adOpenStatic, adLockReadOnly
' Display value, and total recordcount.
MsgBox rs.Fields(3)
MsgBox rs.Fields(8)
'MsgBox rs.RecordCount
stage_Status = rs.Fields(3)
stage_Id = rs.Fields(8)

Set rs = Nothing
Set cn = Nothing

If stage_Status = "True" And stage_Id = "C" Then
MsgBox ("Ok")

     cmd.CommandText = "insert into testreport_tb1 values('" & BrdSrNo & "', 3, GETDATE(), '" & Result & "', NULL, '" & machineName & "', ' KO ', 'A', 'D')"

     Set param = cmd.CreateParameter(BrdSrNo, adVarChar, adParamInput)
     param.Value = BrdSrNo
     param.Size = 25
     cmd.Parameters.Append param
     MsgBox ("Ok")

     Set param = cmd.CreateParameter(Result, adBoolean, adParamInput)
     param.Value = Result
     cmd.Parameters.Append param
     MsgBox ("Ok")

     Set param = cmd.CreateParameter(machineName, adVarChar, adParamInput)
     param.Value = machineName
     param.Size = 10
     cmd.Parameters.Append param
     MsgBox ("Ok")
   
     cmd.ActiveConnection = cn
     cmd.Execute

  MsgBox "saved"
End If
End Sub





我尝试了什么:



尝试打开和关闭Cn.open cn.close



What I have tried:

tried opening and closing Cn.open cn.close

推荐答案

这是您的连接问题。正如我们所指出的那样,完整的错误消息将告诉您连接有什么问题。
This is a problem with your connection. The full error message, as we've been pointing out, will tell you what is wrong with the connection.


这篇关于我得到一个运行时错误3709的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆