是不是还要把dataGrid1绑定什么的?
怎么查找数剧啊
显示到datagrid一般是
sqldataadapter sqlda = new sqldataadapter(cmdtext, sqlconnection)
dataset ds = new dataset();
sqlda.fill(ds)
datagrid.setdatabanding(ds);
搞定,
SqlConnection myconn = new SqlConnection("server=(local);Integrated Security =SSPI;database=liao5930");
string Ssql = "select *from 学生信息表 where(学号="+int.Parse(this.txt1.Text)+")";
SqlCommand cmd = new SqlCommand(Ssql,myconn);
myconn.Open ();
cmd.ExecuteNonQuery();
SqlDataAdapter sqlda = new SqlDataAdapter(Ssql,myconn);
DataTable ds = new DataTable();
sqlda.Fill(ds);
dataGrid1.DataSource=ds.DefaultView;
myconn.Close ();
这个正确,谢谢先
搞定,
SqlConnection myconn = new SqlConnection("server=(local);Integrated Security =SSPI;database=liao5930");
string Ssql = "select *from 学生信息表 where(学号="+int.Parse(this.txt1.Text)+")";
SqlCommand cmd = new SqlCommand(Ssql,myconn);
myconn.Open ();
cmd.ExecuteNonQuery();
SqlDataAdapter sqlda = new SqlDataAdapter(Ssql,myconn);
DataTable ds = new DataTable();
sqlda.Fill(ds);
dataGrid1.DataSource=ds.DefaultView;
myconn.Close ();
这个正确,谢谢先
红色两行字可以去掉,另外通常把connection.open()放在try{}里面,因为数据库经常会连不上
[此贴子已经被作者于2006-10-29 16:30:25编辑过]
搞定,
SqlConnection myconn = new SqlConnection("server=(local);Integrated Security =SSPI;database=liao5930");
string Ssql = "select *from 学生信息表 where(学号="+int.Parse(this.txt1.Text)+")";
SqlCommand cmd = new SqlCommand(Ssql,myconn);
myconn.Open ();
cmd.ExecuteNonQuery();
SqlDataAdapter sqlda = new SqlDataAdapter(Ssql,myconn);
DataTable ds = new DataTable();
sqlda.Fill(ds);
dataGrid1.DataSource=ds.DefaultView;
myconn.Close ();
这个正确,谢谢先
蓝色的都可以去掉.
呵呵.