我想知道我哪错了我不知道怎么改谢谢了

我想知道我哪错了我不知道怎么改谢谢了
public partial class chat_login :System.Web.UI.Page
{
private System.Data.OleDb.OleDbCommand objselectcomm;
private System.Data.OleDb.OleDbConnection objchatconn;
protected void Page_Load(object sender,EventArgs e)
{
}
protected void btn2_Click(object sender,EventArgs e)
{
this.txtname.Text = "";
this.ckbox.Checked = false;
}
protected void ImageButton1_Click(object sender,ImageClickEventArgs e)
{
SqlConnection con=new SqlConnection();
SqlCommand com=new SqlCommand();
string myread="dataread from yonghu3 where name='"+this.txtname.Text+"',pass='"+this.txtpwd.Text+"'";
try
{
if(txtname!=null&&txtpwd!=null)
{
if("dataread from yonghu3 where name='"+this.txtname.Text+"',pass='"+this.txtpwd.Text+"'")
{
con.ConnectionString="server=.;integrated security=sspi;database=yonghu";
com.Connection= con;
com.CommandText=myread;
com.Connection.Open();
com.ExecuteReader();
Response.Redirect("jiyilt1.aspx");
}
else
Label1.Text="用户名或密码不正确";
}
else
Label1.Text="请输入用户名和密码";
}
catch(System.Exception msg)
{
Response.Write(msg.Message.ToString());
}
finally
{
com.Connection.Close();
}
}
protected void ImageButton2_Click(object sender,ImageClickEventArgs e)
{
Response.Redirect("zhuce.aspx");
}
}
编译错误
说明:在编译向该请求提供服务所需资源的过程中出现错误.请检查下列特定错误详细信息并适当地修改源代码.
编译器错误消息:CS0029:无法将类型“string”隐式转换为“bool”
行 41:if("dataread from yonghu3 where name='"+this.txtname.Text+"',pass='"+this.txtpwd.Text+"'")
iam绛洞花王 1年前 已收到1个回答 举报

huanghao0206 幼苗

共回答了25个问题采纳率:96% 举报

if("dataread from yonghu3 where name='"+this.txtname.Text+"',pass='"+this.txtpwd.Text+"'")
你这个东西是string类型,而if里面需要 bool型的,当然报错啦.

1年前

4
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.017 s. - webmaster@yulucn.com