0

I'm want to join 2 table from access database and Microsoft SQL Server 2008 In microsoft visual studio 2008. Display join data in datagridview.

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by yousafc#
0

You have to qualifying the column names. eg. DatabaseName.TableName.Column_Name.

Edited by __avd: n/a

0

Name Space

using System.Data.SqlClient;

Connection string

connString = "Data Source = .\SQL2005;Initial Catalog= lianpiaudatabas;Integrated Security = True";

 try
            {
                DataTable objDT = new DataTable();
               

                SqlConnection objCon = new SqlConnection(conn);
                objCon.Open();

                SqlDataAdapter objDA = new SqlDataAdapter("select * from Table1 Inner join table2 on Table1.table1ID=Table2.Table2ID ",objCon);
                                objDA.Fill(objDT);
                                objCon.Close();

                               this.dataGridView1.DataSource = objDT;

            }
            catch (Exception ex)
            {
                MessageBox.Show("The Systems generated following error: " + ex.Message);
            }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.