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;