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
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)