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 MATLAB动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名