Last post Apr 10, 2012 03:22 AM by Decker Dong - MSFT
Apr 08, 2012 01:46 PM|purnesh.dixit|LINK
Whenever I try to update more than once I get an error COM object that has been separated from its underlying RCW cannot be used.
My code is:
objcmd.Connection = objconn
objcmd.CommandText = "UPDATE Kitchen SET SerialNo=mSerialNo, CustomerName = mCustomerName, ContainerNo = mContainerNo WHERE ABNo = mABNo"
objcmd.ExecuteNonQuery()// This line causes the error
Apr 08, 2012 01:53 PM|Ken Tucker|LINK
I think you are reusing the connection. I would not recommend reusing the connection on a web page. You should create one when you need it, open, use, close, dispose of it.
Apr 09, 2012 09:28 PM|Decker Dong - MSFT|LINK
Please change your commandText to this（by adding "@" as a prefix to declar all kinds of parameters……）
objcmd.CommandText = "UPDATE Kitchen SET SerialNo=@mSerialNo, CustomerName = @mCustomerName, ContainerNo = @mContainerNo WHERE ABNo = @mABNo"
OleDbCommand will automatically find parameters' names accroding to the specific symbol "@"……If you miss it，it's a general command instead of that with parameters。So your error will be thrown out。
Apr 10, 2012 03:00 AM|hans_v|LINK
Decker Dong - MSFT
OleDbCommand will automatically find parameters' names accroding to the specific symbol "@"……
No, OleDb will interpret any identifier it doesn't recognize as a valid table-, query-, field- or function-name as a parameter. Parameters do not need to start with an @, although it is good practice to use them anyway....
Apr 10, 2012 03:22 AM|Decker Dong - MSFT|LINK
Haven't seen you for good……Hummmm……Yes, it's a good habit，I just want to tell the customer the good habit……
Well……another way is you can use ?（question mark）……What do you think of this？