Use of a Join to join two Tables

Asked

Viewed 50 times

0

I wonder if it is possible and indicative to use a Join to "join" values contained in two tables made in a database of the SQL Server. I created two tables and one of them has general information of a client and the other has contact information. What happens is that I separated these two information into two tables because I’m going to put this divided information in the tabs of a tabControl (two pages, in the case).

I was thinking of making one join for ID table with general information, so I could connect all the data of each record.

And in addition, I wonder if it is necessary to create some class to insert these Tables in tabControl or have to do only a select or something like.

CREATE TABLE tblClientes (
ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
Nome varchar(255) NOT NULL,
Telefone varchar(255) NOT NULL,
Tipo varchar(255) NOT NULL, );

SELECT * FROM tblContato
INNER JOIN tblClientes
ON tblContato.ID=tblClientes.ID;
  • I advise creating a view, but Join also resolves

  • Behold that answer to understand how Joins work.

  • Duplicate question, below some issues addressed the same problem. http://answall.com/questions/135168/likeeu-posso-display-users-join?rq=1 http://answall.com/questions/185372/pega-users-join-joinem-duas-tabela-1-para-muitos?rq=1

1 answer

0

After writing the SQL in the form that generates the table with the intended results, you can return this table in a Datatable:

DataTable dt = ConexaoBancoDados.ExecReader(sql);

Then you must create a gridView element to display the data:

gridView.DataSource = dt;
  • But I just want to display in tabControl, have some hint because I’m having trouble understanding how to put the value of Tables in two tabPage

  • You can also use a gridControl.Datasource = Connectiondatabase.Execreader(sql);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.