对一个表列的查询
小弟刚用C#做了一个对表的查询,代码如下。现在想将表wsgdwj_path,wsgdwj两个表联合查询,两个表有个共同的列名_path,需要在我原有的代码上怎么改,求大神指教,小弟先谢过了!
System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Collections;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public SqlConnection m_con = new SqlConnection();
private DataGridView dataGridView = new DataGridView();
private BindingSource bindingSource1 = new BindingSource();
public Form1()
{
InitializeComponent();
}
DataSet wsgdwj = new DataSet();
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
string connsql = String.Format("server=127.0.0.1;Uid=sa;pwd=sasys;database=dnbs;");
//mySqlConnection1 = new MySqlConnection(connStr);
m_con.ConnectionString = connsql;
m_con.Open();
String str = "SELECT *FROM wsgdwj_path ";
SqlDataAdapter da = new SqlDataAdapter(str, m_con);
DataSet ds = new DataSet();
da.Fill(ds, "wsgdwj_path");
//DataGridView dataGridView1 = new DataGridView();
//dataGridView1.DateSource = da;
//dataGridView1.DateBind();
dataGridView1.DataSource = ds.Tables["wsgdwj_path"];
m_con.Close();
}
}
}