错误DataBindings”是“属性”,但此处被当做“方法”来使用
SqlConnection conn = new SqlConnection( "Data Source=PX-JCZX-05;Initial Catalog=wzgl;Integrated Security=True ");
conn.Open();
SqlCommand sql = new SqlCommand( "select * from [azyda] where [xm] like '% " + comboBox2.SelectedValue + "% ' ");
SqlDataAdapter admain = new SqlDataAdapter(sql);
admain.SelectCommand.Connection = conn;
DataSet ds = new DataSet();
admain.Fill(ds, "table ");
ds.Tables[ "table "].Columns[0].ColumnName = "序号 ";
ds.Tables[ "table "].Columns[1].ColumnName = "单位 ";
ds.Tables[ "table "].Columns[2].ColumnName = "设备名称 ";
ds.Tables[ "table "].Columns[3].ColumnName = "规格型号 ";
ds.Tables[ "table "].Columns[4].ColumnName = "机电号 ";
ds.Tables[ "table "].Columns[5].ColumnName = "计量单位 ";
ds.Tables[ "table "].Columns[6].ColumnName = "数量 ";
ds.Tables[ "table "].Columns[7].ColumnName = "使用单位 ";
dataGridView1.DataSource = ds.Tables[ "table "];
dataGridView1.DataBindings();
conn.Close();
conn.Dispose();
提示错误:错误 “System.Windows.Forms.Control.DataBindings”是“属性”,但此处被当做“方法”来使用
是哪里的问题?
------解决方案--------------------dataGridView1.DataBindings();
→→→→→→→
dataGridView1.DataBind();
------解决方案--------------------楼主用winform吧,
winform是不需要“DataBind”的,
获取DataSource就可以了!
------解决方案--------------------为什么一定要加dataGridView1.DataBindings();
dataGridView1.DataSource = ds.Tables[ "table "];这句应该已经显示出数据了
Web页面里的GridVie