private void Pawread()
{
this.textBox1.Text="";
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog = Test;Integrated Security = True;Pooling = False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "select password from t_user where username='"+this.Name+"'";
myCommand.CommandText = sql;
SqlDataReader myDataReader = myCommand.ExecuteReader(); if (myDataReader.HasRows)
{
while (myDataReader.Read())
{
string psw = myDataReader["addressname"].ToString();
}
}
myDataReader.Close();
myConnection.Close();
}
private void button1_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog=Test;Integrated Security =True;Pooling =False"; SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "select password from t_user where username='" + this.Name + "'"; myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
myConnection.Close();
if (textBox1.Text == Pawread( ))
{
if (textBox2.Text == textBox3.Text)
{
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog=Test;Integrated Security =True;Pooling =False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "update t_user set password='" + textBox2.Text + "'where username='" + this.Name + "'";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
myConnection.Close();
}
else
{
MessageBox.Show("两次输入密码不同!");
}
}
else
{
MessageBox.Show("原始密码不正确!");
textBox1.Text = "";
textBox1.Focus();
}
}
提示红色部分错误错误 1 运算符“==”无法应用于“string”和“void”类型的操作数
运算符“==”的用法我可以查到 主要想请大侠们指导该问题具体该如何解决我的目的是修改密码 先验证旧密码的正确性 请不吝赐教 谢谢谢谢
{
this.textBox1.Text="";
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog = Test;Integrated Security = True;Pooling = False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "select password from t_user where username='"+this.Name+"'";
myCommand.CommandText = sql;
SqlDataReader myDataReader = myCommand.ExecuteReader(); if (myDataReader.HasRows)
{
while (myDataReader.Read())
{
string psw = myDataReader["addressname"].ToString();
}
}
myDataReader.Close();
myConnection.Close();
}
private void button1_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog=Test;Integrated Security =True;Pooling =False"; SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "select password from t_user where username='" + this.Name + "'"; myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
myConnection.Close();
if (textBox1.Text == Pawread( ))
{
if (textBox2.Text == textBox3.Text)
{
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog=Test;Integrated Security =True;Pooling =False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "update t_user set password='" + textBox2.Text + "'where username='" + this.Name + "'";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
myConnection.Close();
}
else
{
MessageBox.Show("两次输入密码不同!");
}
}
else
{
MessageBox.Show("原始密码不正确!");
textBox1.Text = "";
textBox1.Focus();
}
}
提示红色部分错误错误 1 运算符“==”无法应用于“string”和“void”类型的操作数
运算符“==”的用法我可以查到 主要想请大侠们指导该问题具体该如何解决我的目的是修改密码 先验证旧密码的正确性 请不吝赐教 谢谢谢谢
解决方案 »
- 问个字符串的 正则表达式表达方法
- C# socket 帮忙解释下啥意思 本人还是菜鸟额
- 问下大家ibatis的分页怎么跟mvc2(或者mvc3)的分页结合?
- 如何利用button控件将Listbox中的选中项上移下移
- 如何用NUnit测试.EXE程序?
- 请问C#中如何在Form窗口上操作office,效果类似于VB的OLE实现(急,在线等)
- 一个关于MapPath函数的问题,请大家帮忙,谢谢
- Text.Encoding.Ascii.....在哪个NameSpace里面??
- 那里有VS.net中属性窗口控件或源代码?
- 不用数据库,c#怎么存储表数据
- 请教2个问题
- 【50分】如何提取Windows消息
if(textBox1.Text.Trim()==paw)
String a = "123";
String b = "123";
//a.Equals()方法代替 "==" 运算符
a.Equals(b);
{
this.textBox1.Text="";
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog = Test;Integrated Security = True;Pooling = False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "select password from t_user where username='"+this.Name+"'";
myCommand.CommandText = sql;
SqlDataReader myDataReader = myCommand.ExecuteReader(); if (myDataReader.HasRows)
{
while (myDataReader.Read())
{
string psw = myDataReader["addressname"].ToString();
}
}
myDataReader.Close();
myConnection.Close();
return psw;
}
这样就不会错了
private string Pawread()
{
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog = Test;Integrated Security = True;Pooling = False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "select password from t_user where username='"+this.Name+"'";
myCommand.CommandText = sql;
SqlDataReader myDataReader = myCommand.ExecuteReader();
string psw = "";
if (myDataReader.HasRows)
{
while (myDataReader.Read())
{
psw= myDataReader["addressname"].ToString();
}
}
myDataReader.Close();
myConnection.Close();
return psw;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == Pawread( ))
{
if (textBox2.Text == textBox3.Text)
{
string connectionString = @"Data Source = CHINA-2FD3DC67C;Initial Catalog=Test;Integrated Security =True;Pooling =False";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open(); SqlCommand myCommand = myConnection.CreateCommand();
string sql = "update t_user set password='" + textBox2.Text + "'where username='" + this.Name + "'";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
myConnection.Close();
}
else
{
MessageBox.Show("两次输入密码不同!");
}
}
else
{
MessageBox.Show("原始密码不正确!");
textBox1.Text = "";
textBox1.Focus();
}
}