-
October 1st, 2009, 01:15 AM
#1
enter a value from dropdownlist to database
I have a checkbox which when enabled the value of the dropdownlist is entered in database and if not enabled a default value should be enterd in the database....
my code is :
if (CheckBox2.Checked)
{
DropDownList1.Enabled = true;
string oeec = DropDownList1.SelectedValue.ToString();
}
else
{
string oeec = "1000";
}
System.Data.SqlClient.SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString =
@"Data Source=JAGMIT-PC\SQLEXPRESS;Initial Catalog=SumooHAgentDB;Integrated Security=True";
System.Data.SqlClient.SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
dataCommand.CommandText = ("Insert Policies ( NotifyOnEnvErrorCount) values (@oeec)");
dataCommand.Parameters.AddWithValue("@oeec",oeec);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
dataConnection.Close();
with this i get an error
Error 1 The name 'oeec' does not exist in the current context
-
October 1st, 2009, 01:29 AM
#2
Re: enter a value from dropdownlist to database
-
October 1st, 2009, 02:11 AM
#3
Re: enter a value from dropdownlist to database
can you tell what did you change to make it work ?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|