Sulieman Alkatib

Sulieman Alkatib

  • NA
  • 56
  • 4.7k

insert values into table using dataset and dropdownlist

May 24 2017 12:05 PM
Hi
I just finish dataSet codes as followed:
 
SELECT date_E, adminname
FROM event
WHERE (ID = ?)
 
I have a dropDownList that allows user to select ID only and the system will insert date_E and adminname into that table
 
what is the proper code to get date_e and adminname to use it in my function
  1. protected void Button1_Click(object sender, EventArgs e)  
  2.         {  
  3.             string id = DropDownList1.SelectedValue;  
  4.   
  5.               
  6.   
  7.             OleDbConnection con = new OleDbConnection("connectionstring");  
  8.             try  
  9.             {  
  10.                 OleDbCommand cmd = con.CreateCommand();  
  11.                 con.Open();  
  12.                 cmd.CommandText = "Insert into customer Values('" + Session["UserName"] + "','" + ????? + "' , '" + DropDownList1.SelectedValue + "' , '" + ????? + "')";  
  13.                 cmd.Connection = con;  
  14.                 cmd.ExecuteNonQuery();  
  15.   
  16.                 con.Close();  
  17.                 Label3.Text = "Registered successfully";  
  18.             }  
  19.             catch (Exception)  
  20.             {  
  21.                Label3.Text = "database connection problem";  
  22.   
  23.   
  24.   
  25.             }  
  26.   
  27.         }  
 

Answers (5)