c# 请问我想比较从 textbox中传到后台的字符串与数据库中查询的字符串怎么搞?

来源:百度知道 编辑:UC知道 时间:2024/06/17 18:38:56
textbox 叫 rewords 请问哪错了 谢谢~~
protected void answer_Click(object sender, EventArgs e)
{
string strConnection = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("baobaoxiong1.mdb");
OleDbConnection conn = new OleDbConnection(strConnection);
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT Chinese FROM [baobaoxiong1] where id=" + a;
conn.Open();
OleDbDataReader dcmd = cmd.ExecuteReader();
if (dcmd="+this.rewords.text+")
Response.Redirect("baobaoxiong6.htm");
else
Response.Redirect("baobaoxiong7.htm");
我是初学者 谢谢
请问 "+this.rewords.text+" 中+ 号是什么用?
郁闷死

string strConnection = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("baobaoxiong1.mdb");
OleDbConnection conn = new OleDbConnection(strConnection);
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT Chinese FROM [baobaoxiong1] where id=" + a;
conn.Open();
OleDbDataReader dcmd = cmd.ExecuteReader();
if (dcmd=="+this.rewords.text+")
{Response.Redirect("baobaoxiong6.htm");}
else
{Response.Redirect("baobaoxiong7.htm");}
C#中比较是== 不是=
=是负值

if (dcmd=="+this.rewords.text+")
还有格式
if()
{}
else
{}

if(dcmd.read())
{
if(this.rewords.text.Equals(dcmd.getString("Chinese")))
{
Response.Redirect("baobaoxiong6.htm");
}
else
Response.Redirect("baobaoxiong7.htm");

}