Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# - DataSet Not Saving
Message
 
To
15/04/2008 11:15:58
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01310720
Message ID:
01310735
Views:
14
Mike,

Thank. I'm playing around with it but I can't seem to get it. Could you provide an example?


>Kevin,
>DataSets are disconnected from the source. The AcceptChanges() method does not have anything to do with the data source - it just notifies the DataSet to mark itself as current. You have to manually save the DataSet back to the source, and that involves a SQLCommand object configured with an Update SQL command (or Stored Proc).
>
>>Ok, what am I doing wring here. This compiles and runs, but the changes are not sent to SQL.
>>DSCustomer is a typed dataset. The DataSet Visualize shows the new row.
>>
>>
>>/*****************************************************
>> * Get the customer dataset
>>******************************************************/
>>
>>string sSelectCommand = "select * from Customers where CustomerKey = 1";
>>
>>SqlDataAdapter oDataAdapter = new SqlDataAdapter(sSelectCommand, oConnection);
>>DSCustomer oDataSet = new DSCustomer();
>>oDataAdapter.Fill(oDataSet, "DSCustomer");
>>
>>/*****************************************************
>> * Or Create an empty customer dataset
>>******************************************************/
>>//DSCustomer oDataSet = new DSCustomer();
>>
>>// Add a blank row
>>oDataSet.Tables[0].Rows.Add();
>>
>>
>>// Get a reference to the table
>>DataTable oTable = oDataSet.Tables[0];
>>
>>// Get the number of rows
>>int iRowCount = oTable.Rows.Count - 1;
>>
>>// Get a reference to the last row
>>DataRow oRow = oTable.Rows[iRowCount];
>>
>>// Edit the column values
>>oRow["CustomerName"] = "Someone Else";
>>oRow["CreditLimit"] = 15;
>>
>>// Save the changes
>>oDataSet.AcceptChanges();
>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform