大侠们请进:C#数据库更新问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 07:35:50
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 图书馆管理系统
{
public partial class user : Form
{
private OleDbConnection oleConnection1 = null;
public user()
{
InitializeComponent();
this.oleConnection1 = new OleDbConnection(图书馆管理系统.database.dbConnection.connection);
}

private void button1_Click(object sender, EventArgs e)
{
oleConnection1.Open();
string sql = "select UName as 用户名,PWD as 密码 from userinfo where UName='"+textBox1.Text+"'";
DataSet cd = new DataSet();
OleDbDataAdapter cmd = new OleDbDataAdapter(sql, oleConnection1);
OleDbCommandBuil

string sql = "delete * from userinfo where UName='"+ textBox1.Text+"'";
改成
string sql = "delete from userinfo where UName='"+ textBox1.Text+"'";
顺便说一句:SQL关键字最好大写,便于查看和纠错
----------------------
纠正一下,删除语句也可以这么写的,w3school上说的,只是这么写不太常用而已。

delete * from userinfo where UName='"+ textBox1.Text+"'";
sql语句错啦!

delete from userinfo where UName....
再试试

SQL删除语句问题