|
-
Jun 10th, 2008, 09:53 PM
#1
Thread Starter
Hyperactive Member
Array Problem (Object is no longer valid)
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
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Jun 11th, 2008, 04:59 AM
#2
Thread Starter
Hyperactive Member
Re: Array Problem (Object is no longer valid)
I found that the error only occur when i execute store procedure after 2nd items. If i ignore the error and start the breakpoint for next parameter array it will resume as normally. but the adodb.parameter array for that index could not store different value.
Hope someone can really help me , Thanks for a million..
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|