ADO.NET and C/S app

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone point me an example for using Ado .Net in a C/S applicaiton in a
connected mode ?
I want to achieve something like Ado's server side cursor.

Thanks
 
Hi Trebor,

ADO.NET has (almost) no support for connected mode.
You might import Ado and use it as you've always used it (with some
limitations), see
Accessing an ADO Recordset or Record from ADO.NET
..net help topic.
Why would you want to use connected mode, btw?
 
Hi Trebor,
ADO.NET has (almost) no support for connected mode.
You might import Ado and use it as you've always used it (with some
limitations), see
Accessing an ADO Recordset or Record from ADO.NET
.net help topic.
Why would you want to use connected mode, btw?


I plan to replace /rewrite OLTP Win32 app for accounting which uses ADO with
WinForms and Ado.Net.

So I thought that the connected mode is better for OLTP applications.

Thanks.
 
Hi Trebor,

I strongly suggest you to go with the flow - ado.net and disconnected way.
 
I strongly suggest you to go with the flow - ado.net and disconnected way.

OK, but now I need some support / clarification for solving problems like
this:

For ex..
Imagine a simplified OLTP model with only 2 tables:

- Products (productId varchar (10), ProductName varchar (100))
and
- Orders (OrderNo integer,
ProductId varchar(10),
Quantity numeric(10,3),
Price numeric (10,2));

Product is a code table, and Orders is a table where intensive insert,
update and delete operation occurs:


Suppose that user1 opened a connection and filled the dataset with Orders
and Product tables
and disconnected.
In the mean time user2 deleted the product with value 123456 from the
Products table.
How can I prevent user1 from entering records with productId=123456 into
Orders table?

Thanks
 
HI Trebor,

You are describing a concurrency issue.
The easiest way is to store some sort of timestamp along with each record.
It should be modified when record changes.
Now, when you do update or delete you would check if timestamp you have in
memory is the same as one in the database.
(this is normally done in "where" part of sql statament).
If it doesn't match, you might rise an error or do something else.
You might read
Introduction to Data Concurrency in ADO.NET
..net help chapter.
Believe me, disconnected is better than connected. Imagine (connected model)
a client that opens a data for editing and then goes home without closing
it. The whole application might have problems cause of this...
 
You are describing a concurrency issue.

Yes it is concurency issue.
The easiest way is to store some sort of timestamp along with each record.
It should be modified when record changes.
Now, when you do update or delete you would check if timestamp you have in
memory is the same as one in the database.
(this is normally done in "where" part of sql statament).

The problem is that the users are already used to enjoy the benefits of an
OLTP application with FIELD level validation.They got an exception (alert)
immediately after they left the ProductId field
(if there is problem with missing value or similar.)

I'm not sure that they will easlily accept the record level validation
(or even worse validation of the whole set of previously entered records)
Introduction to Data Concurrency in ADO.NET
.net help chapter.

Thanks, I' ll read this chapter for sure.
Believe me, disconnected is better than connected. Imagine (connected model)
a client that opens a data for editing and then goes home without closing
it. The whole application might have problems cause of this...

Not exactly, if you implement an inactivity timeout in your application,
the connection will be cut off immediately after the timeout period
expired.

Thanks,
 
Hi Trebor,
The problem is that the users are already used to enjoy the benefits of an
OLTP application with FIELD level validation.They got an exception (alert)
immediately after they left the ProductId field
(if there is problem with missing value or similar.)

I'm not sure that they will easlily accept the record level validation
(or even worse validation of the whole set of previously entered records)

Well, yes, but normally, one does not overwrite other's data often does
he/she?
But of course, it depends on your user and the application.
Not exactly, if you implement an inactivity timeout in your application,
the connection will be cut off immediately after the timeout period
expired.

True, but in the meantime the records or table is locked to anybody plus the
user will loose all of his/her data (posibly without any reason - timeout
doesn't know if it is really necessary).
 
Ah no. ADO.NET can (and is) used for connected AND disconnected
applications. There are plenty of people out there doing both. Yes, it's
true that ADO.NET does not include native support for server-side cursors,
but these can be created by using the ANSI OPEN CURSOR method. There is
nothing to stop you from opening your own connection and holding it open (to
manage the state), just as you did with ADO classic--assuming you know the
impact of your operations (as it appears you do).

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Miha Markic said:
Hi Trebor,

ADO.NET has (almost) no support for connected mode.
You might import Ado and use it as you've always used it (with some
limitations), see
Accessing an ADO Recordset or Record from ADO.NET
.net help topic.
Why would you want to use connected mode, btw?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Can someone point me an example for using Ado .Net in a C/S applicaiton
in
a
connected mode ?
I want to achieve something like Ado's server side cursor.

Thanks
 
Back
Top