david @ epsom dot com dot au
9/7/2006 11:49:00 AM
You may not be able to connect to a ''stored procedure'' like
that. (I haven''t tried). If that is your problem, you need to
create a ''parameter query'' instead of a ''stored procedure''
Do you know if your mdb is in ''Jet'' mode or ''SQL Server''
mode? Do you know how the query was created? If you
open the mdb in Access 2000, can you see the query
listed in the database window? If so, what is the SQL?
(david)
"Jaime Lucci" <jaimelucci@hotmail.com> wrote in message
news:uXsU40JyGHA.2220@TK2MSFTNGP02.phx.gbl...
> Hi everyne
>
> I`m trying to run aan acces query with parameters from VB 2005. If I do it
> with OleDB components I have no problems, but I need to do that with ODBC,
> but I get this error:
>
> ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Invalid SQL
> statement; expected ''DELETE'', ''INSERT'', ''PROCEDURE'', ''SELECT'', or
''UPDATE''.
>
> The code is the following:
>
> Dim CnnODBC As Odbc.OdbcConnection
> Dim cmd As Odbc.OdbcCommand
> ''Connect to database
> CnnODBC = New Odbc.OdbcConnection("DSN=asd")
> CnnODBC.Open()
> ''The ms access query
> cmd = New Odbc.OdbcCommand("AgregarCliente", CnnODBC)
> cmd.CommandType = CommandType.StoredProcedure
> ''Parameters
> With cmd.Parameters
> .Add("paramRazonSocial", txtRazonSocial.Text)
> .Add("paramDomicilio", txtDomicilio.Text)
> .Add("paramNumCliente", txtNumCliente.Text)
> End With
> ''Execution
> cmd.ExecuteNonQuery()
> ''Disconnect
> CnnODBC.Close()
>
> The error occurs in the execute line. Can you help me?
>
> Thanks
>
> Jaime Lucci.
>
>
>