c# 语言asp.net 查询数据库表中的一个数据,怎么将其他的数据在页面中textbox显示出来
我自己做的代码、打不开求改正。voidButton2_Click(objectsender,EventArgse){stringsql,strconnection;str...
我自己做的代码、打不开求改正。
void Button2_Click(object sender, EventArgs e) {
string sql,strconnection;
strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+Server.MapPath("User.mdb");
OleDbConnection conn= new OleDbConnection(strconnection);
conn.Open();
sql="select proname,quantity,discount from product where proname='"+TextBox1.Text+"'";
OleDbCommand Cmd=new OleDbCommand(sql, conn);
OleDbDataReader read=Cmd.ExecuteReader();
if(read.Read())
{
TextBox4.Text=read["proname"].ToString();
TextBox2.Text=read["quantity"].ToString();
TextBox3.Text=read["discount"].ToString();
}
} 展开
void Button2_Click(object sender, EventArgs e) {
string sql,strconnection;
strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+Server.MapPath("User.mdb");
OleDbConnection conn= new OleDbConnection(strconnection);
conn.Open();
sql="select proname,quantity,discount from product where proname='"+TextBox1.Text+"'";
OleDbCommand Cmd=new OleDbCommand(sql, conn);
OleDbDataReader read=Cmd.ExecuteReader();
if(read.Read())
{
TextBox4.Text=read["proname"].ToString();
TextBox2.Text=read["quantity"].ToString();
TextBox3.Text=read["discount"].ToString();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |