C
ck
I apologize for cross posting, this is just driving me crazy. I have been
beating myself up all day trying to find one good example of adArray as part
of a parameter. I went this route.
Sub Test1()
dim cn as new adodb.Connection
dim s$
s = "Provider=Microsoft.Jet.OleDb.4.0; Data Source = somefile.mdb;"
cn.Open s
dim cmd as new adodb.Command
with cmd
..ActiveConnection = cn
.CommandText = "SELECT CompanyName From [Names] WHERE NameType IN ?"
.CommandType = adCmdText
End With
Dim ax() As String
ReDim ax(1) As String
ax(0) = "Member"
ax(1) = "Exhibitor"
With prm1
.Type = 8392 'Errors right about here, I want the Array ( ax() in
this example ) to provide the parameter values for an SQL IN Clause
.Direction = adParamInput
.Size = 20
.Value = ax()
End With
cmd.Parameters.Append prm1
Dim rs As New ADODB.Recordset
rs.Open cmd, , adOpenStatic, adLockPessimistic
Debug.Print rs.RecordCount
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
I have also tried cmd.Parameters.Append cmd.CreateParameter(, adArray or
adVarChar, adParamInput, 20, az()). I get an error saying wrong type of
arguments. I have tried just about possible DataType in the Array, Also
tried adVarray + adVarChar, still doen't worh right.
Any ideas? If you see anything obvious or any suggestions to try it a
different way, please let me know. Thank you to all whom reply.
Regards,
kc
beating myself up all day trying to find one good example of adArray as part
of a parameter. I went this route.
Sub Test1()
dim cn as new adodb.Connection
dim s$
s = "Provider=Microsoft.Jet.OleDb.4.0; Data Source = somefile.mdb;"
cn.Open s
dim cmd as new adodb.Command
with cmd
..ActiveConnection = cn
.CommandText = "SELECT CompanyName From [Names] WHERE NameType IN ?"
.CommandType = adCmdText
End With
Dim ax() As String
ReDim ax(1) As String
ax(0) = "Member"
ax(1) = "Exhibitor"
With prm1
.Type = 8392 'Errors right about here, I want the Array ( ax() in
this example ) to provide the parameter values for an SQL IN Clause
.Direction = adParamInput
.Size = 20
.Value = ax()
End With
cmd.Parameters.Append prm1
Dim rs As New ADODB.Recordset
rs.Open cmd, , adOpenStatic, adLockPessimistic
Debug.Print rs.RecordCount
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
I have also tried cmd.Parameters.Append cmd.CreateParameter(, adArray or
adVarChar, adParamInput, 20, az()). I get an error saying wrong type of
arguments. I have tried just about possible DataType in the Array, Also
tried adVarray + adVarChar, still doen't worh right.
Any ideas? If you see anything obvious or any suggestions to try it a
different way, please let me know. Thank you to all whom reply.
Regards,
kc