【发布时间】:2013-10-09 17:38:09
【问题描述】:
我的代码没有向数据库添加组合框值。这里可能有什么问题?
private void Submit_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source=CEX-PC\SQLEXPRESS;"
+ "Initial Catalog=inventorydatabase;"
+ "Integrated Security=True";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string query
= "INSERT INTO userdetail (username, password, position) VALUES ('"
+ username.Text + "', '" + password.Text + "', '"
+ position.SelectedValue + "' )";
SqlCommand command = new SqlCommand(query, con);
command.ExecuteNonQuery();
con.Close();
}
【问题讨论】:
-
名称和密码是否插入?
-
Windows 或 Web 应用程序
-
@Bart Friederichs 是的
-
@Steve 没有错误信息
-
我的代码有什么问题吗?
标签: c# sql winforms sql-server-express