insert data in sql using c# winform application?
  • I have a three textbox in desktop application every textbox have a different value but i have one column in sql database i want to insert every textbox value using loop how can i insert data of textbox?
  • 1 Comment sorted by
  • Vote Up0Vote Down WaqasWaqas
    172.00 Karma Accepted Answer
    hi you can try this code for looping on all form textboxes


    private void button1_Click(object sender, EventArgs e)
    {
    foreach (var Control in this.Controls)
    {
    if (Control is TextBox)
    {
    string txtValue= ((TextBox)Control).Text;
    string query = "Insert into table_name (ColumnName) Values ('" + txtValue + "')";
    //run here cmd.ExecuteNonQuery();
    }
    }
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative