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 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿