G
Guest
I am probably missing something obvious, but I cant seem to get this to work.
I have been reading several posts and trying different combinations, but the
gist is that the server database never gets updated with the changed dataset.
The Clinic Table does have a primary key. If i make a call to
da.UpdateCommand = cb.GetUpdateCommand() i get a runtime error saying:
Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information.
When i comment out that line the code seems to run, but it doesnt update the
server data.
Any help would be greatly appreciated!
public partial class UserInfo : Form
{
SqlConnection Iconnection;
SqlDataAdapter da;
SqlCommandBuilder cb;
DataSet ds;
public UserInfo()
{
InitializeComponent();
Iconnection = InvDB.GetInvConnection();
Iconnection.Open();
string sqlString = "SELECT uid, clinic_name, clinic_id, "+
"clinic_address1, clinic_address2, clinic_city, "+
"clinic_state, clinic_zip, clinic_country, clinic_url, "+
"clinic_inquiry_contact, clinic_phone1, clinic_phone2, "+
"clinic_fax, clinic_email, clinic_product_code, "+
"clinic_support_plan, clinic_install_date FROM dbo.Clinic";
da = new SqlDataAdapter(sqlString,Iconnection);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
cb = new SqlCommandBuilder(da);
da.InsertCommand = cb.GetInsertCommand();
ds = new DataSet();
da.Fill(ds, "dbo.Clinic");
this.clinicBindingSource.DataSource = ds;
this.clinicBindingSource.DataMember = "dbo.Clinic";
}
private void clinicBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
{
this.Validate();
this.clinicBindingSource.EndEdit();
ds.AcceptChanges();
da.Update(ds.Tables["dbo.Clinic"]);
I have been reading several posts and trying different combinations, but the
gist is that the server database never gets updated with the changed dataset.
The Clinic Table does have a primary key. If i make a call to
da.UpdateCommand = cb.GetUpdateCommand() i get a runtime error saying:
Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information.
When i comment out that line the code seems to run, but it doesnt update the
server data.
Any help would be greatly appreciated!
public partial class UserInfo : Form
{
SqlConnection Iconnection;
SqlDataAdapter da;
SqlCommandBuilder cb;
DataSet ds;
public UserInfo()
{
InitializeComponent();
Iconnection = InvDB.GetInvConnection();
Iconnection.Open();
string sqlString = "SELECT uid, clinic_name, clinic_id, "+
"clinic_address1, clinic_address2, clinic_city, "+
"clinic_state, clinic_zip, clinic_country, clinic_url, "+
"clinic_inquiry_contact, clinic_phone1, clinic_phone2, "+
"clinic_fax, clinic_email, clinic_product_code, "+
"clinic_support_plan, clinic_install_date FROM dbo.Clinic";
da = new SqlDataAdapter(sqlString,Iconnection);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
cb = new SqlCommandBuilder(da);
da.InsertCommand = cb.GetInsertCommand();
ds = new DataSet();
da.Fill(ds, "dbo.Clinic");
this.clinicBindingSource.DataSource = ds;
this.clinicBindingSource.DataMember = "dbo.Clinic";
}
private void clinicBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
{
this.Validate();
this.clinicBindingSource.EndEdit();
ds.AcceptChanges();
da.Update(ds.Tables["dbo.Clinic"]);