string strConnection = ConfigurationManager.ConnectionStrings["Harfosh.Properties.Settings.TYT"].ConnectionString;
//string strConnection = "ConfigurationManager.ConnectionStrings[Store_Manager.Properties.Settings.storemanagerConnectionString].Name;";
SqlConnection con = new SqlConnection(strConnection);
con.Open();
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = con;
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = "Select rakmsanf ,esmsanf,esmmwrd,m5zn,quantity,w7da,reorder from Items Where m5zn =N'" + comboBox2.Text + "' ";
SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd);
System.Data.DataTable dtRecord = new System.Data.DataTable();
sqlDataAdap.Fill(dtRecord);
// DataGridView dataGridView1 = new DataGridView();
dataGridView1.DataSource = dtRecord;
if (dataGridView1.Columns[0] != null)
dataGridView1.Columns[0].HeaderText = "Key";
if (dataGridView1.Columns[1] != null)
dataGridView1.Columns[1].HeaderText = "Expire";
con.Close();
现在我得到rakmsanf,esmsanf,esmmwrd,m5zn,quantity,w7da,reorder AND key Expire
我想将列标题更改为Key - Expire
,不需要查看rakmsanf ,esmsanf,esmmwrd,m5zn,quantity,w7da,reorder
(更改所选标题名称)
答案 0 :(得分:0)
您可以按以下方式更改SQL
Select rakmsanf as [-رقم الصنف] ,esmsanf as Expire from Items Where m5zn ='N'
然后您不需要通过代码
来完成答案 1 :(得分:0)
您可以在此ff中更改Datagridview Column标头。步骤进行:
希望它有效。