C#如何读取ACCESS某个数据并显示在文本框?
谁帮我写一句话,可以吗?让SQL读到的数据显示到文本框,怎么写?stringConn="provider=microsoft.jet.oledb.4.0;datasour...
谁帮我写一句话,可以吗?
让SQL读到的数据显示到文本框,怎么写?
string Conn = "provider=microsoft.jet.oledb.4.0;data source=AutoDesk.mdb";
OleDbConnection myCon = new OleDbConnection(Conn); //连接到数据库
myCon.Open();
string Str = " select [title] as titlex from [Note] where ID=25";
OleDbCommand myCmd = new OleDbCommand(Str, myCon);
myCmd.ExecuteNonQuery();
carserial.Text = Str;
myCon.Close(); 展开
让SQL读到的数据显示到文本框,怎么写?
string Conn = "provider=microsoft.jet.oledb.4.0;data source=AutoDesk.mdb";
OleDbConnection myCon = new OleDbConnection(Conn); //连接到数据库
myCon.Open();
string Str = " select [title] as titlex from [Note] where ID=25";
OleDbCommand myCmd = new OleDbCommand(Str, myCon);
myCmd.ExecuteNonQuery();
carserial.Text = Str;
myCon.Close(); 展开
1个回答
展开全部
参考代码:
String Str = " select [title] as titlex from [Note] where ID=25";
OleDbCommand command = new OleDbCommand(Str);
command.Connection = conn;
OleDbDataReader dr = null;
conn.Open();
dr = command.ExecuteReader();
while (dr.Read())
{
carserial.Text = (dr["carserial"].ToString());
}
conn.Close();
String Str = " select [title] as titlex from [Note] where ID=25";
OleDbCommand command = new OleDbCommand(Str);
command.Connection = conn;
OleDbDataReader dr = null;
conn.Open();
dr = command.ExecuteReader();
while (dr.Read())
{
carserial.Text = (dr["carserial"].ToString());
}
conn.Close();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |