qq_27602361 2015-04-21 15:06 采纳率: 61.5%
浏览 1744
已采纳

标准表达式中数据类型不匹配

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
public partial class 登录界面 : Form
{
OleDbDataAdapter adapter;
DataTable table = new DataTable();
string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\hospital\data.accdb";

        OleDbConnection connection = new OleDbConnection();


    public 登录界面()
    {
        InitializeComponent();
    }
    private void textbox1_TextChanged(object sender, EventArgs e)
    {
    }
    private void textbox2_TextChanged(object sender, EventArgs e)
    {
    }
    private void radioButton1_CheckedChanged(object sender, EventArgs e)
    {

    }
    private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {

    }
    private void radioButton3_CheckedChanged(object sender, EventArgs e)
    {

    }
    private void radioButton4_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (textBox1.Text != "" && textBox2.Text != "")
        {
            string sql = "select * from [user]  where ID ='" + textBox1.Text + "' and 密码 = '" + textBox2.Text + "'";
            adapter = new OleDbDataAdapter(sql, str);
            OleDbCommandBuilder buider = new OleDbCommandBuilder(adapter);
            adapter.InsertCommand = buider.GetInsertCommand();
            table.Clear();
            adapter.Fill(table);
            if (table.Rows.Count > 0)
            {
                Form 挂号缴费界面 = new 挂号缴费界面();
                this.Hide();
                挂号缴费界面.Show();
            }
        }


        if (radioButton1.Checked == true)
        {
            this.Hide();
            new 挂号缴费界面().ShowDialog();

        }
        else if (radioButton2.Checked == true)
        {
            this.Hide();
            new 医生诊断界面A().ShowDialog();
        }
        else if (radioButton3.Checked == true)
        {
            this.Hide();
            new 护士病房管理界面A().ShowDialog();
        }
        else if (radioButton4.Checked == true)
        {
            this.Hide();
            new 药房界面A().ShowDialog();
        }
        else
        {
            MessageBox.Show("请输入信息");
        }
    }
    private void button2_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }
    private void 登录界面_Load(object sender, EventArgs e)
    {
     textBox1.Text = textBox2.Text = string.Empty; 
    }

    private void 登录界面_Load_1(object sender, EventArgs e)
    {

    }


}

}

系统运行到 adapter.Fill(table); 提示标准表达式中数据类型不匹配

  • 写回答

4条回答

  • threenewbee 2015-04-21 15:10
    关注

    那就去掉单引号

      string sql = "select * from [user]  where ID ='" + textBox1.Text + "' and 密码 = " + textBox2.Text;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 优质github账号直接兑换rmb,感兴趣伙伴可以私信
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)