Database Reference
In-Depth Information
// Insert department
da.Update(ds, "HumanResources.Department");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
finally
{
//Connection close
conn.Close();
}
}
6. To set the PersistAddsBuilder form as the start-up form, modify the Program.cs
statement.
Application.Run(new PersistAdds());
to appear as:
Application.Run(new PersistAddsBuilder());
Build the project, and run it by pressing Ctrl+F5. You should see the results in
Figure 15-14.
Figure 15-14. Adding a row using a command builder
How It Works
The most interesting thing to note isn't the line (yes, just one plus a comment) you add as much as what
you replace.
// create command builder
SqlCommandBuilder cb = new SqlCommandBuilder(da);
// Add a row
DataRow newRow = dt.NewRow();
newRow["Name"] = "Language Design";
newRow["GroupName"] = "Research and Development";
 
Search WWH ::




Custom Search