**我想更改MS访问数据库中的密码但它无法正常工作&它在UPDATE语句中显示语法错误,请帮助我的朋友。数据库包含Roll表,名称,电子邮件,密码文件**
using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
namespace ConsoleApplication1
{
public class DBConnect
{
private static OleDbConnection NewCon;
private static string conStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\MY FILES\PL\LIBRARY.mdb";
public static OleDbConnection getConnection()
{
NewCon = new OleDbConnection(conStr);
return NewCon;
}
public DBConnect()
{
}
}
class Program
{
static void Main(string[] args)
{
OleDbConnection dbConnection;
dbConnection = DBConnect.getConnection();
if (dbConnection.State.ToString() == "Closed")
{
dbConnection.Open();
}
OleDbCommand command = new OleDbCommand("UPDATE Register SET Password=@Npwd WHERE Roll=@Roll AND Password=@Cpwd);", dbConnection);
command.Parameters.AddWithValue("@Roll", "12cs0144");
command.Parameters.AddWithValue("@Cpwd", "434");
command.Parameters.AddWithValue("@Npwd", "123");
int temp = command.ExecuteNonQuery();
if (temp != 0)
{
Console.WriteLine("True");
}
dbConnection.Close();
Console.ReadLine();
}}}