Hi all. have just dragged a datagridview control onto a form. this loads up a sql d/b fine and appropriately. the grid is editable (new rows can be added/changed etc)Now i need those changes to be thrown back to the d/b - how do i do that ? many thanks for reading!

this is what i have so far:

private void SaveBtn_Click(object sender, EventArgs e)
        {
             SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=blah;Integrated Security=True");
             SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[blahUserDetails] ([username], [password], [role], [email], [telephone], [organization], [fax], [address], [created], [expiry], [modified]) VALUES (@username, @password, @role, @email, @telephone, @organization, @fax, @address, @created, @expiry, @modified");
             cmd.ExecuteNonQuery();
             MessageBox.Show("done");
        }

have fixed some silly mistakes I made lol

private void SaveBtn_Click(object sender, EventArgs e)
        {
             SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=nats;Integrated Security=True");
             SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[natsUserDetails] ([username], [password], [role], [email], [telephone], [organization], [fax], [address], [created], [expiry], [modified]) VALUES (@username, @password, @role, @email, @telephone, @organization, @fax, @address, @created, @expiry, @modified");
             conn.Open(); 
             int recs = cmd.ExecuteNonQuery();
             MessageBox.Show("done");
        }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.