程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ccess-標准表達式中數據類型不匹配

ccess-標准表達式中數據類型不匹配

編輯:編程綜合問答
標准表達式中數據類型不匹配

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); 提示標准表達式中數據類型不匹配

最佳回答:


那就去掉單引號

  string sql = "select * from [user]  where ID ='" + textBox1.Text + "' and 密碼 = " + textBox2.Text;
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved