خرید بک لینک

Vote count: 0

Hi guys please help me on how to save all data coming textbox and i store it to datatable and i can view it to datagridview. How can I save all the data to database. Advance thanks, here's my sample code:

private void add_Click(object sender, EventArgs e) { if (txtAddEmail.Text.Trim() == "") { MessageBox.Show("Please enter Email Address.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAddEmail.Focus(); txtAddEmail.Visible = true; return; } dt.Rows.Add(txtAddEmail.Text); dgvEmailAdd.DataSource = dt; txtAddEmail.Text = ""; SaveEmail(); }

    private void SaveEmail()
    {
        try
        {
            string strDBConfig = Application.StartupPath + @"MedXPro.xml";

            using (SqlCoection co = PSCSClass.DataCoections.MDFCoection("", "", false, "", "", strDBConfig))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Coection = co;
                    for (int i = 0; i < dgvEmailAdd.Rows.Count; i++)
                    {
                        string StrQuery = @"INSERT INTO EmailAddress (EmailAddress) VALUES ("
                            + dgvEmailAdd.Rows[i].Cells["Email Address"].Value + ");";
                        cmd.CommandText = StrQuery;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

asked 14 secs ago

برچسب: how to save money,how to save a life,how to save a life lyrics,how to save youtube videos,how to save in mafia 3,how to save a video from facebook,how to save snapchat videos,how to save gifs,how to save a life chords,how to save for a house, نویسنده: استخدام کار تاريخ: يکشنبه 18 مهر 1395 ساعت: 21:50

صفحه بندی