C#修改密码的问题

来源:百度知道 编辑:UC知道 时间:2024/06/23 23:45:53
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsApplication1
{
public partial class UpdateForm : Form
{
public UpdateForm()
{
InitializeComponent();
}

private void btnOK_Click(object sender, EventArgs e)
{
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=D:\个人重要资料(勿删)\Administrator\My Documents\Visual Studio 2005\WindowsApplication1\WindowsApplication1\bin\Debug\db_RGS.mdb";
OleDbConnection con = new OleDbConnection(strConnection);
con.Open();
string selectsql1 =string.Format( "SELECT user_i

string selectsql1 ="SELECT user_id,user_pow FROM [user] where user_id='" + this.textLoginID.Text + "' and user_pow='" + this.textOldPwd.Text + "'";

string updatesql1 =string.Format( "update [user] set user_pow='" + this.textNewPwd.Text + "' where user_id='" + this.textLoginID.Text + "'");
中 user_id如果是整型的话,换成
string updatesql1 =string.Format( "update [user] set user_pow='" + this.textNewPwd.Text + "' where user_id=" + int.Parse(this.textLoginID.Text) + "");

好象少了个sql引用System.Data.SqlClient

string selectsql1 =string.Format( "SELECT user_id,user_pow FROM [user] where user_id='" + this.textLoginID.Text + "' and user_pow='" + this.textOldPwd.Text + "'");
这里的sql语句查询的是两个字段
而cmdd.ExecuteScalar(); 这个方法返回的是一个值
所以报错了.你可以查询一个字段就行了吧
弱弱的问一句 真的会给俺 50分吗?