正在将下拉菜单的内容复制到数据库
本文关键字:复制 数据库 下拉菜单 | 更新日期: 2023-09-27 18:00:47
我正试图将下拉菜单的内容复制到SQL数据库中。但是,当我运行以下代码时,我会得到下拉菜单列表的名称。如何显示下拉菜单的值?这里的代码Label4和Label5是下拉菜单。感谢
protected void Button4_Click(object sender, EventArgs e)
{
SqlConnection sc = new SqlConnection();
SqlCommand com = new SqlCommand();
sc.ConnectionString = ("Data Source=FRMDEVSQL03; Initial Catalog=VisualStudioTest;");
sc.Open();
com.Connection = sc;
com.CommandText = (@"INSERT INTO ticket(person_created, category_id, summary, ticket_status) VALUES ('" + txtName.Text + "', '" + Label5.Text + "', '" + txtName0.Text + "', '" + Label4.Text + "');");
com.CommandText = (@"INSERT INTO persons(LanID) VALUES ('" + txtName.Text + "');");
//com.CommandText = (@"INSERT INTO ticket(person_created, summary) VALUES ('" + txtName.Text + "','" + txtName0.Text + "');");
com.ExecuteNonQuery();
sc.Close();
Response.Redirect(Request.RawUrl);
}
protected void Button4_Click(object sender, EventArgs e)
{
Insertdata()
}
public void Insertdata()
{
SqlConnection sc = new SqlConnection();
SqlCommand com = new SqlCommand();
sc.ConnectionString = ("Data Source=FRMDEVSQL03; Initial Catalog=VisualStudioTest; User ID=Aghosh; Password=SummerClerk");
sc.Open();
com.Connection = sc;
com.CommandText = (@"INSERT INTO ticket(person_created, category_id, summary, ticket_status) VALUES ('" + txtName.Text + "', '" + Label5.selectedvalue + "', '" + txtName0.Text + "', '" + Label4.selectedvalue + "');");
com.CommandText = (@"INSERT INTO persons(LanID) VALUES ('" + txtName.Text + "');");
//com.CommandText = (@"INSERT INTO ticket(person_created, summary) VALUES ('" + txtName.Text + "','" + txtName0.Text + "');");
com.ExecuteNonQuery();
sc.Close();
Response.Redirect(Request.RawUrl);
}