Hi All ,
vb Code:
Do While Not rs.EOF ReDim Preserve objparameter(0) With objparameter(0) .Direction = adParamInput .Type = adVarChar .Size = 50 .Value = Me.lblNewRef.Caption End With ReDim Preserve objparameter(1) With objparameter(1) .Direction = adParamInput .Type = adVarChar .Size = 50 .Value = rs.Fields(1) End With ReDim Preserve objparameter(2) With objparameter(2) .Direction = adParamInput .Type = adVarChar .Size = 100 .Value = rs.Fields(2) End With ReDim Preserve objparameter(3) With objparameter(3) .Direction = adParamInput .Type = adVarChar .Size = 100 .Value = rs.Fields(3) End With ReDim Preserve objparameter(4) With objparameter(4) .Direction = adParamInput .Type = adVarChar .Size = 150 .Value = rs.Fields(4) End With Set rs_1 = SP_SQL(gdb, "SP_INSERT_ProdDetail", objparameter()) rs.MoveNext Loop Public Function SP_SQL(pstrDBName As String, StorePro As String, ByRef objparameter() As ADODB.Parameter) As ADODB.Recordset Dim intCountParam As Integer Call SQLExecute(pstrDBName) Set adoCommand = New ADODB.Command With adoCommand If Not IsEmpty(objparameter()) Then For intCountParam = 0 To UBound(objparameter()) adoCommand.Parameters.Append objparameter(intCountParam) Next End If .ActiveConnection = conn .CommandType = adCmdStoredProc .CommandText = StorePro End With Set rs = adoCommand.Execute Set SP_SQL = rs End Function Public Sub SQLExecute(pstrDBName As String) Set conn = New ADODB.Connection conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _ "Persist Security Info=true;" & _ "Initial Catalog=Local Mattress System;User Id=;Password=;Data Source=SHLIM\SQLEXPRESS;" conn.Open End Sub
Above is my vb code with public function.
I met a error "Object is no longer valid" on objparameter(adodb.parameter)
I search a lot of source from internal to solve my problem, unfortunately is can't get exactly help. I hope someone of here can help me... thanks




Reply With Quote