datagrid最开始加载进去的是一张医生信息表 MIS_Doctor 的全部信息
dname = this.txtname.text; //获得界面输入的医生姓名
///开始 查询
...conn.open();
string selectcmd = SELECT * FROM MIS_Doctor where DoctorName = ' " + dname + " '; //SQL语句
SqlCommand sc2 = new SqlCommand(selectcmd,conn); //
现在我不知道怎么把查询到的结果通过datagrid显示出来
==============================================================
加载datagrid的代码是
connstr =
"Server=LENOVO-8AD35F65;database=ZXMR;uid = sa;pwd = sa;";
selectcmd = "SELECT * FROM MIS_Patient ORDER BY PatientID DESC";
SqlConnection conn;
SqlDataAdapter myadapter;
DataSet mydataset = new DataSet();
conn = new SqlConnection(connstr);
myadapter = new SqlDataAdapter(selectcmd,conn);
myadapter.Fill(mydataset,"MIS_Patient");
dataGrid1.DataSource = mydataset.Tables["MIS_Patient"];