Using a join to join two tables

0

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

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

And besides, I would like to know if it is necessary to create some class to do the insertion of these tables in tabControl or it has to do only a select or something of the type.

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;
    
asked by anonymous 16.03.2017 / 04:25

1 answer

0

After you write SQL in the way that you generate the table with the desired results, you can return this table in a DataTable:

DataTable dt = ConexaoBancoDados.ExecReader(sql);

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

gridView.DataSource = dt;
    
16.03.2017 / 12:51