enter a value from dropdownlist to database
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: enter a value from dropdownlist to database

  1. #1
    Join Date
    Jan 2009
    Posts
    22

    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

  2. #2
    Join Date
    Jan 2009
    Posts
    22

    Re: enter a value from dropdownlist to database

    ok i got it........

  3. #3
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    422

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center