Emilylai 2015-06-04 10:00 采纳率: 50%
浏览 1489
已采纳

请问一下在.net中这样的错误怎么解决?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace KTV前台
{
public partial class 包场模式 : Form
{
public 包场模式()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection("server=.;database=ktv;integrated security=true;");
private void 选择包间_Load(object sender, EventArgs e)
{

    }

    private void button2_Click(object sender, EventArgs e)
    {
        if (textBox1.Text == "")
        {
            MessageBox.Show("请输入房间号!", "提示");
        }
        else
        {
            conn.Open();
            if (comboBox3.Text == "上午场(8:00---12:00)")
            {
                 SqlCommand a = new SqlCommand("Select * from 房间信息 where 房间ID='"+textBox1.Text +"'",conn);
                 a.ExecuteNonQuery();
                 SqlCommand com = new SqlCommand("insert into 房间信息(模式,小时数,总价) values('" + comboBox3.Text + "','4','300') ", conn);
                com.ExecuteNonQuery();
                MessageBox.Show("添加成功", "提示");

            }
            else if (comboBox3.Text == "下午场(12:30---5:30)")
            {
                SqlCommand com = new SqlCommand("insert into 房间信息(模式,小时数,总价)values('" + comboBox3.Text + "','5','400')", conn);
                com.ExecuteNonQuery();
                MessageBox.Show("添加成功", "提示");


            }
            else if (comboBox3.Text == "黄金场(7:00---12:00)")
            {
                SqlCommand com = new SqlCommand("insert into 房间信息(房间ID,模式,小时数,总价) values('" + textBox1.Text + "','" + comboBox3.Text + "','5','1000')", conn);
                com.ExecuteNonQuery();
                MessageBox.Show("添加成功", "提示");


            }
            else if (comboBox3.Text == "午夜场(12:30--5:00)")
            {
                SqlCommand com = new SqlCommand("insert into 房间信息(房间ID,模式,小时数,总价) values('" + textBox1.Text + "','" + comboBox3.Text + "','5','300')", conn);
                com.ExecuteNonQuery();
                MessageBox.Show("添加成功", "提示");

            }
            conn.Close();
        }
    }
}

}

图片说明

  • 写回答

1条回答

  • threenewbee 2015-06-04 10:05
    关注

    检查数据库中有没有模式这一列。它的类型和你用的类型是否相符。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog