C#语句 在线等这解决

问题描述:

C#语句 在线等这解决
string connStr = @"Data Source=.;Initial Catalog=zmgl;Integrated Security=True";//验证账户密码形式
//创建数据库连接对象
SqlConnection conn = new SqlConnection(connStr);

//定义数据库查询语句
string sql = "select * from ma";
//创建执行sql语句的对象
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
//执行sql语句
DataSet ds = new DataSet();
sda.Fill(ds);


//显示数据
//this.dataGridView1.DataSource = ds.Tables[0];
//a = ds.Tables[0].Rows[0][0].ToString();
if (textBox1 .Text == ds.Tables[0].Rows[0][0].ToString ())
{
MessageBox.Show("密码正确!");
}
else
{
MessageBox.Show("密码错误!");
}
textBox1 .Text 的数据和ds.Tables[0].Rows[0][0].ToString ()数据是一致的 为什么提示 密码错误呢
1个回答 分类:综合 2014-10-29

问题解答:

我来补答
textBox1 .Text 的数据和ds.Tables[0].Rows[0][0].ToString ()数据是一致的?可能是肉眼看是一致,但计算机就认为是不一致.
textBox1 .Text == ds.Tables[0].Rows[0][0].ToString ()改为:
textBox1 .Text.ToUpper() == ds.Tables[0].Rows[0][0].ToString ().ToUpper()
如果还不正确,再加.Trim()
再不正确,你调试一下.
 
 
展开全文阅读
剩余:2000
上一页:求形状的题不会