Group:  Microsoft Access ยป microsoft.public.access.odbcclientsvr
Thread: Access with ODBC from VB 2005

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Access with ODBC from VB 2005
"Jaime Lucci" <jaimelucci[ at ]hotmail.com> 25.08.2006 23:21:35
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.



Re: Access with ODBC from VB 2005
"Jim Hughes" <NOSPAMJ3033[ at ]Hotmail.com> 29.08.2006 13:21:20
The command verbs supported by ODBC are not as rich as those available from
OleDB.

If OleDB works, I would use OleDB.

If it is an issue of connection strings, check out
www.connectionstrings.com.

What SQL statement is contained in AgregarCliente?

Remember that you can not include VBA functions in SQL statements that will
be executed outside of Access.

"Jaime Lucci" <jaimelucci[ at ]hotmail.com> wrote in message
news:uXsU40JyGHA.2220[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> 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.
>
>
>


Re: Access with ODBC from VB 2005
<david[ at ]epsomdotcomdotau> 07.09.2006 11:49:01
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[ at ]hotmail.com> wrote in message
news:uXsU40JyGHA.2220[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> 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.
>
>
>



Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net