problem with SELECT

  • Thread starter Thread starter David Fúnez
  • Start date Start date
D

David Fúnez

Hi;

Why, if i use the code #1 works fine, but if i use the code #2 launches an
error, it doesn't let me concatenate the SELECT.

Any help

Thanks on advance.

*** code #1 all in a single line***
cmd.CommandText = "SELECT a.Id_producto, a.Nombre, a.Precio, b.nombrepre
FROM producto a, presentacion b WHERE a.id_presentacion = b.id_presentacion"

*** code #2 ***
cmd.CommandText = "SELECT a.Id_producto," & _
"a.Nombre, a.Precio, b.nombrepre" & _
"FROM producto a, presentacion b" & _
"WHERE a.id_presentacion = b.id_presentacion"
 
At a quick glance it looks like you're missing some spaces in #2. Try
this...

cmd.CommandText = "SELECT a.Id_producto," & _
"a.Nombre,a.Precio,b.nombrepre " & _
"FROM producto a,presentacion b " & _
"WHERE a.id_presentacion=b.id_presentacion"
 
Because there have to be *spaces* in between things. If you went through
the trouble of basic debugging like outputting the string variable you'd see
it looks like this:

SELECT a.Id_producto,a.Nombre, a.Precio, b.nombrepreFROM producto a,
presentacion bWHERE a.id_presentacion = b.id_presentacion

The undoubted bad syntax exception you're getting would also point you to
that conclusion.


--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate
 
Back
Top