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");
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.