 |
| SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 26th, 2009, 09:06 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
How to Join 2 tables in to 1
Hi There
I Have 2 tables and need to get 2 columns from tabel1 and 3 columns from table2.
I Have this So far:
Code:
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT SLP05.CUSN05, SLP05.CNAM05, SimDefault.SimNet, SimDefault.Cost, SimDefault.Commission FROM SimDefault CROSS JOIN SLP05()WHERE (SLP05.CUSN05 = @CUSN05)"
cmd.Parameters.Add("@CUSN05", Data.SqlDbType.Char, 8).Value = Me.TextBox1.Text
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As DataSet = New DataSet
da.Fill(ds, "CUSN05")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "CUSN05"
But i get this error:
Parameters supplied for object 'SLP05' which is not a function. If the parameters are intended as a table hint, a WITH keyword is required.
thanks
__________________
bx
|
|

June 26th, 2009, 09:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Hello..
I think that () after SLP05 is useless...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

June 26th, 2009, 10:22 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
Thanks that was it
gbianchi i have a little question??
How to make the Query to ingnore the spaces ;
I have a text box that you enter the company name than you click search, the SQL command runs to the database and checks 4 the exact match.
i need to search 4 minimum of 5 karacters and % after.
I know that i have to use the LIKE thing but i dont know exactly how >>
can you post something regarding this?
i have this buti it only works with the first letter in the textbox, if i type mor it returns no data
cmd.CommandText = "SELECT SLP05.CNAM05, SLP05.CUSN05, SimDefault.SimNet, SimDefault.Cost, SimDefault.Commission FROM SimDefault CROSS JOIN SLP05 Where (SLP05.CNAM05 Like '" & txtName.Text & " %')"
__________________
bx
Last edited by bex; June 26th, 2009 at 10:46 AM..
|
|

June 26th, 2009, 10:51 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
did you try the querys directly on the database?? the query looks perfectly fine, it should be working (but you have a space before the % that should not be there...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

June 26th, 2009, 10:58 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
thanks
1 little space :)
__________________
bx
|
|

June 26th, 2009, 11:26 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
Can i pass this to a textbox insted of a DataGrid?
__________________
bx
|
|

June 26th, 2009, 02:21 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
A select??? only if you return only one row/column... and you use executescalar
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

June 26th, 2009, 03:46 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
That is not good for me,
I asked that cos i have a print button that i want to print the DataGrid, I got it working with the textbox, but not with the Datagrid, Is there a way to print grid data?
__________________
bx
|
|

June 27th, 2009, 03:24 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
gbianchi I Have a Job in SQL 2005 Importing Data From SQL2000. Every time the job runs it imports the data but creates duplicates, how to stop this from creating duplicates?
I Just Need Updates
__________________
bx
|
|

June 27th, 2009, 05:17 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
You are not giving me any information that could help me solve this... you are getting duplicates, but why, I can't tell you without knowing how this thing works, SQL involved, when do it run, etc...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
 |