连接access数据库后实现查询功能在datagridview控件里显示,代码具体该怎么写
privatevoidbutton1_Click(objectsender,EventArgse){OleDbConnectionOleDbConn=newOleDbCo...
privatevoid button1_Click(objectsender, EventArgs e)
{
OleDbConnectionOleDbConn = newOleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;datasource=112.mdb;Persist Security Info=False");
OleDbConn.Open();
stringstr = "selectstudent.sid,student.sname,student.sage ,student.telephone from student wheresid='"+textBox1.Text.Trim()+"'order by sid";
OleDbDataAdapterda = newOleDbDataAdapter(str,OleDbConn);
DataSetds = newDataSet();
da.Fill(ds, "123");
OleDbConn.Close();
} 展开
{
OleDbConnectionOleDbConn = newOleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;datasource=112.mdb;Persist Security Info=False");
OleDbConn.Open();
stringstr = "selectstudent.sid,student.sname,student.sage ,student.telephone from student wheresid='"+textBox1.Text.Trim()+"'order by sid";
OleDbDataAdapterda = newOleDbDataAdapter(str,OleDbConn);
DataSetds = newDataSet();
da.Fill(ds, "123");
OleDbConn.Close();
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |