Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
5
Reply
insert values into table using dataset and dropdownlist
Sulieman Alkatib
May 24 2017 12:05 PM
270
Reply
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
protected void Button
1
_Click(object sender, EventArgs e)
{
string id = DropDownList
1
.SelectedValue;
OleDbConnection con = new OleDbConnection(
"connectionstring"
);
try
{
OleDbCommand cmd = con.CreateCommand();
con.Open();
cmd.CommandText =
"Insert into customer Values('"
+ Session[
"UserName"
] +
"','"
+ ????? +
"' , '"
+ DropDownList
1
.SelectedValue +
"' , '"
+ ????? +
"')"
;
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
Label
3
.Text =
"Registered successfully"
;
}
catch (Exception)
{
Label
3
.Text =
"database connection problem"
;
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
Age after 10 years
C# combobox web link in visual studio 2015