我嘗試從2個不同的表中填充datagridview,它是nonMember和下面的代碼的客戶...但datagridview不顯示除灰色背景之外的任何內容。從不同的表填充Datagridview c#
using (SqlConnection connection = new SqlConnection(ConnectionString))
using (SqlCommand cmd = connection.CreateCommand())
{
connection.Open();
cmd.CommandText = "@SELECT tbl_nonMember.*, tbl_customer.customerID AS Expr1, tbl_customer.lname, tbl_customer.fname, tbl_customer.mname, tbl_customer.gender, tbl_customer.age, tbl_customer.membership_type FROM tbl_customer INNER JOIN tbl_nonMember ON tbl_customer.customerID = tbl_nonMember.customerID";
SqlDataAdapter adap = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adap.Fill(ds);
dataGridView2.DataSource = ds.Tables[0].DefaultView;
}
您是否已將DataGridView設置爲自動生成列? – thewisegod
還沒有,我無法在DataGridView屬性中找到自動生成列.. – Josh