qq_27410413 2015-04-25 13:44 采纳率: 0%
浏览 1573
已采纳

数据写不进去access表中,怎么改呢?

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 专科医院门诊系统_眼科_
{

public partial class 挂号界面 : Form
{

    OleDbConnection con = new OleDbConnection();
    string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\design\vc\project\专科医院门诊系统(眼科)\db1.accdb";
    public 挂号界面()
    {
        InitializeComponent();
        con.ConnectionString = str;
        button1.Click += new EventHandler(button1_Click);
        button2.Click += new EventHandler(button2_Click);
        button3.Click += new EventHandler(button3_Click);
    }
    private void textBox1_TextChanged(object sender, EventArgs e)
    {

    }

    private void textBox2_TextChanged(object sender, EventArgs e)
    {

    }

    private void textBox3_TextChanged(object sender, EventArgs e)
    {

    }

    private void textBox4_TextChanged(object sender, EventArgs e)
    {

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

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

    }   
    private void button1_Click(object sender, EventArgs e)
    {
        挂号缴费选择界面 frm = new 挂号缴费选择界面();
        frm.Show();
        Hide();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        if (textBox1.Text != "" && textBox2.Text != ""&& textBox3.Text != ""&& textBox4.Text != ""&& textBox5.Text != ""&& textBox6.Text != "")
        {
        string a = textBox1 .Text ;
        string b = textBox2 .Text ;
        string c = textBox3 .Text ;
        string d = textBox4 .Text ;
        string f = textBox5 .Text ;
        string g = textBox6 .Text ;
        OleDbCommand cmd = new OleDbCommand(@"insert into [patient](ID,名字,年龄,性别,电话号码,科室)  values(" + a + ",'" + b + "'," + c + ",'" + d + "',"+ f + ",'"+ g + "')");
        con.Open();
        cmd.Connection = con;
        cmd.ExecuteNonQuery();
        con.Close();
        MessageBox.Show("挂号成功!");
        }
        else
        {

         MessageBox .Show ("请输入完整的挂号信息");
        }



        textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = string.Empty;
    }
    private void button3_Click(object sender, EventArgs e)
    {
        textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text =textBox6.Text = string.Empty;
    }
    private void 挂号界面_Load(object sender, EventArgs e)
    {

    }
}

}
图片说明
图片说明
图片说明

  • 写回答

2条回答 默认 最新

  • devmiao 2015-04-25 13:56
    关注

    采纳,将代码发网盘,可以帮你。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形