
Parameterized SQL statements with ADO.Command object
I think you're trying to over-complicate the code. You don't need to
use the Parameter object with dynamic SQL
Try..
Dim cmdCommand As New Command
Dim rsRecSet As Recordset
cmdCommand.ActiveConnection =
"Provider=Microsoft.Jet.OLEDB.3.51;Data Source=M:
\DEV\LAMA\VBfiles\test.mdb;"
cmdCommand.CommandText = "SELECT ShapeBase,ShapeHeight,ShapeForm
FROM ShapeTable WHERE ShapeName=" & GetName
cmdCommand.Prepared = True
Set rsRecSet = SQLConnection.Execute
Also, if you do use the parameter object, you must do it thus..
Dim cmdCommand as New Command
Dim adoParam As Parameter
Dim rsRecSet As RecordSet
cmdCommand.ActiveConnection =
"Provider=Microsoft.Jet.OLEDB.3.51;Data Source=M:
\DEV\LAMA\VBfiles\test.mdb;"
Set adoParam = cmdCommand.CreateParameter("ParamName", adChar,
adParamInput, 20, GetName)
cmdCommand.Parameters.Add adoParam
Jason Goff MCP(VB5)
Marketsquare Software Ltd
Quote:
> I'm trying to execute this code and this is the error message I get:
> "-2147217839 (80040e51) The provider cannot derive parameter info and
> SetParameterInfo has not been called"
> Dim cmdCommand As New Command
> Dim rsRecSet As New Recordset
> cmdCommand.ActiveConnection =
"Provider=Microsoft.Jet.OLEDB.3.51;Data Source=M:
\DEV\LAMA\VBfiles\test.mdb;"
Quote:
> cmdCommand.CommandText = "SELECT ShapeBase,ShapeHeight,ShapeForm
FROM ShapeTable WHERE ShapeName= ?"
Quote:
> cmdCommand.Prepared = True
> cmdCommand.Parameters(0).value = GetName
> Set shape = SQLConnection.Execute
> Can anyone help med please! Thanks alot!
> //Kristoffer Lindn
> -----------------** -- Posted from CodeGuru -- **-----------------
> http://www.codeguru.com/vb The website for VB programmers.
--
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.