qq_27410413 2015-04-23 12:30 采纳率: 0%
浏览 1626

visual c# 和access的 运行没错误,但是调试了运行没反应 button2

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
{

    public 挂号界面()
    {
        InitializeComponent();
    }


    private void button1_Click(object sender, EventArgs e)
    {
        挂号缴费选择界面 frm = new 挂号缴费选择界面();
        frm.Show();
        Hide();
    }
    private void button2_Click(object sender, EventArgs e)
    {
        string a = textBox1 .Text ;
        string b = textBox2 .Text ;
        string c = textBox3 .Text ;
        string d = textBox4 .Text ;
        string f = textBox5 .Text ;
        string g = textBox6 .Text ;
        OleDbConnection conn = new OleDbConnection();
        conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\design\vc\project\专科医院门诊系统(眼科)\db1.accdb";
        conn.Open();
        string str = "insert into patient ([ID],名字,年龄,性别,电话号码,科室) values (('" + a + "','" + b + "','" + c + "','" + d + "','" + f + "','" + g + "')";
        OleDbCommand cmd=new OleDbCommand();
        cmd.Connection=conn;
        cmd.CommandText=str;
        cmd.ExecuteNonQuery();
        cmd.Dispose();
        conn.Close();
        conn.Dispose();
        MessageBox.Show("挂号成功");
    }
    private void button3_Click(object sender, EventArgs e)
    {
        textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = string.Empty;
    }
    private void 挂号界面_Load(object sender, EventArgs e)
    {

    }
}

}

难道是数据库连接或者 insert 语句错误吗?
求大神帮忙看下,帮我改下,小弟实在是小白啊

  • 写回答

5条回答 默认 最新

  • qq_27410413 2015-04-23 12:34
    关注

    图片说明
    图片说明
    加了几段代码后就这样子了 。 大神帮忙改下把 !!!!

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)