-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Pithvi
Message 6 in Discussion
This is a known issue with ADO.NET update. Previous data access technologies such
as ADO include features that let you submit changes automatically. With ADO.NET,
you can submit changes using the DataAdapter object, but the
DataAdapter does not automatically include the logic required to submit updates. Lets
see how it works with ADO then we will see how we can do this in ADO.NET Dim rs As
ADODB.RecordsetSet rs = New ADODB.Recordsetrs.CursorLocation = adUseClientrs.Open
strSQL, strConn, adOpenStatic, adLockBatchOptimistic, adCmdText
rs.Deleters.MoveNext rs.Fields("Quantity") = 2 * rs.Fields("Quantity")rs.Update if u
run this code and look at your sql profiler you will find
commands like this generated. DELETE FROM [Order Details] WHERE OrderID = 10503 AND
P roductID = 14 UPDATE [Order Details] SET Quantity = 40 WHERE OrderID = 10503 AND
ProductID = 65 AND Quanti ty = 20 I think now u should be clear enough why you got
that error with ADO.NET so use oledbcommand object to execute (executenonquery) a
delete/Update/Insert parametersied query. Something like this static OleDbCommand
CreateDeleteCommand() { string strSQL; strSQL = "DELETE FROM [Order Details] "
+ " WHERE OrderID = ? AND ProductID = ? AND " + "
Quantity = ? AND UnitPrice = ?"; OleDbCommand cmd = new OleDbCommand(strSQL, cn);
OleDbParameterCollection pc = cmd.Parameters; pc.Add("OrderID",
OleDbType.Integer); pc.Add("ProductID", OleDbType.Integer); pc.Add("Quantity",
OleDbType.SmallInt); pc.Add("UnitPrice", OleDbType.Currency); return cmd; }
then check the executenonquery return value to check, whether the execution was
successful or not. if it is successful execute a Acceptchanges and now u got your
updated data
-Cheers- Prithvi :)
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]