刚刚建立啦windows 窗体应用程序
想向数据库里面添加数据 连接已经成功
可是我发现啦一个问题
对于 控件 combox 的使用
我在属性Item 中写啦 两行 ‘男’,‘女’
当我在窗体上添加数据选择 男 的时候
显示 插入数据成功
我打开 我所连接的数据库 发现
他生成的不是‘男’
而是 其他的的东西
能告诉我为什么吗
帮我看看
代码
在下面
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private SqlConnection myConnection;
private SqlCommand myCommand;
private void Form1_Load(object sender, EventArgs e)
{
myConnection = new SqlConnection ("server=.;Initial Catalog=Text;Integrated Security=SSPI ");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
myConnection.Open();
string sql = "insert into Passenger_table values('" + this.textBox1.Text + " ','" + this.textBox2.Text + " ','" + this.textBox3.Text + " ','" + this.textBox4.Text + "','"+()+"', '" + this.textBox5.Text + "')";
myCommand = new SqlCommand(sql, myConnection);
myCommand.ExecuteNonQuery();
MessageBox.Show("插入成功");
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myConnection.Close();
}
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
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 comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
try
{
myConnection.Open();
myCommand = new SqlCommand("delect * from Passenger_table where flightID='" + textBox1 + "'", myConnection);
myCommand.ExecuteNonQuery();
MessageBox.Show("删除成功");
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myConnection.Close();
}
}
}
}
这个虽然很基础 但是
不知道怎么搞