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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记