Using INNER JOIN with SQL 
Author Message
 Using INNER JOIN with SQL

Hello everybody,

Im new in this section (I mean programming with Visual Basic language)
and I have problems when using the following code. A message box like
"sintax error using INNER JOIN  - Code no 3135" appears.

Here is the code:

Private Sub Form_Load()
Set db = OpenDatabase("c:\trueno\trueno.mdb")

DBGrid1.AllowUpdate = False
varcons = Form2.DBGrid1.Columns(0)

varcon = "select [prodprov.codigo], [prodprov.cod-prov], [Proveedores.Desc]"
varcon = varcon & " FROM prodprov INNER JOIN Proveedores ON
[prodprov.cod-prov] = [Proveedores.Cod-Prov]"
varcon = varcon & " WHERE prodprov.codigo = " & varcons
Data1.RecordSource = varcon
Data1.Refresh
Sub

I want to join two tables containing a same field each one.
I have passed fours day thinking of it without succeded.
Could anyone help me with this code, please.?

Sorry for my bad english, Im from Argentina
Thank you



Fri, 18 Jul 2003 23:59:58 GMT  
 Using INNER JOIN with SQL
The problem you are having is not with your VB code, but with your SQL
statement, which is parsed by the database engine of whatever RDBMS
you are using. The best way to debug SQL statements is by using the
tools that come with the product -- the query window for Access, the
Query Analyzer with SQL Server. You'll also have to handle the issue
of delimiters for non-numeric variables--each engine supports slightly
different syntax.

-- Mary
Microsoft Access Developer's Guide to SQL Server
http://www.amazon.com/exec/obidos/ASIN/0672319446/mcwtechnologies/

On Mon, 29 Jan 2001 12:59:58 -0300, "Fernando Flores"

Quote:

>Hello everybody,

>Im new in this section (I mean programming with visual basic language)
>and I have problems when using the following code. A message box like
>"sintax error using INNER JOIN  - Code no 3135" appears.

>Here is the code:

>Private Sub Form_Load()
>Set db = OpenDatabase("c:\trueno\trueno.mdb")

>DBGrid1.AllowUpdate = False
>varcons = Form2.DBGrid1.Columns(0)

>varcon = "select [prodprov.codigo], [prodprov.cod-prov], [Proveedores.Desc]"
>varcon = varcon & " FROM prodprov INNER JOIN Proveedores ON
>[prodprov.cod-prov] = [Proveedores.Cod-Prov]"
>varcon = varcon & " WHERE prodprov.codigo = " & varcons
>Data1.RecordSource = varcon
>Data1.Refresh
>Sub

>I want to join two tables containing a same field each one.
>I have passed fours day thinking of it without succeded.
>Could anyone help me with this code, please.?

>Sorry for my bad english, Im from Argentina
>Thank you



Sat, 19 Jul 2003 01:21:02 GMT  
 Using INNER JOIN with SQL
Mary,

Thanks for the help, Ill try that way. I have seen the book at the site you
wrote in the e-mail, Will it help me
with this problem ?, remember that Im using data access but with Visual
Basic, no directly SQL
( I mean simple SQL instruccions with Vb code to get data access ), and do
you know where to look for a
spanish version ?

Thank you again
Best regards,
Fernando



Quote:
> The problem you are having is not with your VB code, but with your SQL
> statement, which is parsed by the database engine of whatever RDBMS
> you are using. The best way to debug SQL statements is by using the
> tools that come with the product -- the query window for Access, the
> Query Analyzer with SQL Server. You'll also have to handle the issue
> of delimiters for non-numeric variables--each engine supports slightly
> different syntax.

> -- Mary
> Microsoft Access Developer's Guide to SQL Server
> http://www.amazon.com/exec/obidos/ASIN/0672319446/mcwtechnologies/

> On Mon, 29 Jan 2001 12:59:58 -0300, "Fernando Flores"

> >Hello everybody,

> >Im new in this section (I mean programming with visual basic language)
> >and I have problems when using the following code. A message box like
> >"sintax error using INNER JOIN  - Code no 3135" appears.

> >Here is the code:

> >Private Sub Form_Load()
> >Set db = OpenDatabase("c:\trueno\trueno.mdb")

> >DBGrid1.AllowUpdate = False
> >varcons = Form2.DBGrid1.Columns(0)

> >varcon = "select [prodprov.codigo], [prodprov.cod-prov],
[Proveedores.Desc]"
> >varcon = varcon & " FROM prodprov INNER JOIN Proveedores ON
> >[prodprov.cod-prov] = [Proveedores.Cod-Prov]"
> >varcon = varcon & " WHERE prodprov.codigo = " & varcons
> >Data1.RecordSource = varcon
> >Data1.Refresh
> >Sub

> >I want to join two tables containing a same field each one.
> >I have passed fours day thinking of it without succeded.
> >Could anyone help me with this code, please.?

> >Sorry for my bad english, Im from Argentina
> >Thank you



Sat, 19 Jul 2003 03:42:53 GMT  
 Using INNER JOIN with SQL
Hi!
The Table names and the Field names should have their own set of brackets,
like...
[prodprov].[cod-prov],  NOT like [prodprov.cod-prov].
Also, using "Desc" as a  field name can cause problems.
Also, if varcons is a string, it needs to be in quotes, like
" WHERE prodprov.codigo = ' " & varcons & " ' "  (but without the spaces
between quotes)
If varcons is an integer, it doesn't need quotes.
Hope this helps!
SR

Quote:
> Hello everybody,

> Im new in this section (I mean programming with visual basic language)
> and I have problems when using the following code. A message box like
> "sintax error using INNER JOIN  - Code no 3135" appears.

> Here is the code:

> Private Sub Form_Load()
> Set db = OpenDatabase("c:\trueno\trueno.mdb")

> DBGrid1.AllowUpdate = False
> varcons = Form2.DBGrid1.Columns(0)

> varcon = "select [prodprov.codigo], [prodprov.cod-prov],
[Proveedores.Desc]"
> varcon = varcon & " FROM prodprov INNER JOIN Proveedores ON
> [prodprov.cod-prov] = [Proveedores.Cod-Prov]"
> varcon = varcon & " WHERE prodprov.codigo = " & varcons
> Data1.RecordSource = varcon
> Data1.Refresh
> Sub

> I want to join two tables containing a same field each one.
> I have passed fours day thinking of it without succeded.
> Could anyone help me with this code, please.?

> Sorry for my bad english, Im from Argentina
> Thank you



Sat, 19 Jul 2003 04:06:01 GMT  
 Using INNER JOIN with SQL
sorry, don't know about spanish versions. One other tip is to use
variables and then Debug.Print statements so you can take a look at
the entire string in the immediate window. a simple "debug.print
varcon" might point up where the connection is failing.

-- Mary
Microsoft Access Developer's Guide to SQL Server
http://www.amazon.com/exec/obidos/ASIN/0672319446/mcwtechnologies/

On Mon, 29 Jan 2001 16:42:53 -0300, "Fernando Flores"

Quote:

>Mary,

>Thanks for the help, Ill try that way. I have seen the book at the site you
>wrote in the e-mail, Will it help me
>with this problem ?, remember that Im using data access but with Visual
>Basic, no directly SQL
>( I mean simple SQL instruccions with Vb code to get data access ), and do
>you know where to look for a
>spanish version ?

>Thank you again
>Best regards,
>Fernando



>> The problem you are having is not with your VB code, but with your SQL
>> statement, which is parsed by the database engine of whatever RDBMS
>> you are using. The best way to debug SQL statements is by using the
>> tools that come with the product -- the query window for Access, the
>> Query Analyzer with SQL Server. You'll also have to handle the issue
>> of delimiters for non-numeric variables--each engine supports slightly
>> different syntax.

>> -- Mary
>> Microsoft Access Developer's Guide to SQL Server
>> http://www.amazon.com/exec/obidos/ASIN/0672319446/mcwtechnologies/

>> On Mon, 29 Jan 2001 12:59:58 -0300, "Fernando Flores"

>> >Hello everybody,

>> >Im new in this section (I mean programming with visual basic language)
>> >and I have problems when using the following code. A message box like
>> >"sintax error using INNER JOIN  - Code no 3135" appears.

>> >Here is the code:

>> >Private Sub Form_Load()
>> >Set db = OpenDatabase("c:\trueno\trueno.mdb")

>> >DBGrid1.AllowUpdate = False
>> >varcons = Form2.DBGrid1.Columns(0)

>> >varcon = "select [prodprov.codigo], [prodprov.cod-prov],
>[Proveedores.Desc]"
>> >varcon = varcon & " FROM prodprov INNER JOIN Proveedores ON
>> >[prodprov.cod-prov] = [Proveedores.Cod-Prov]"
>> >varcon = varcon & " WHERE prodprov.codigo = " & varcons
>> >Data1.RecordSource = varcon
>> >Data1.Refresh
>> >Sub

>> >I want to join two tables containing a same field each one.
>> >I have passed fours day thinking of it without succeded.
>> >Could anyone help me with this code, please.?

>> >Sorry for my bad english, Im from Argentina
>> >Thank you



Sat, 19 Jul 2003 23:30:22 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. SELECT . INNER JOIN--INNER JOIN

2. Using ado recordset in an SQL Server inner join

3. Automatic SQL Generation for INNER JOINs

4. SQL INNER JOIN

5. SQL - INNER JOIN syntax

6. Help: INNER JOIN problem, any SQL-Gurus ?

7. INNER JOINS SQL from VB

8. VB5: SQL statement with INNER JOIN

9. SQL Inner Join Query

10. sql guru's - need help with an inner join

11. Inner join with case insensitive match in SQL

12. sql query problem for inner join

 

 
Powered by phpBB® Forum Software