Solved

Asynchronous send command to SQL Server with ADO.NET

Posted on 2009-07-01
7
267 Views
Last Modified: 2013-12-17
Hi experts!

  Im using C# 2008 , WinForm NET 2, ADO.NET and SQL Server 2005 with connection model connection, reader and command. Im interesting what are my option to have Asynchronous execution to SQL Server ? I want to do this for not so important save to DB and to avoid user to wait for this end .

Asynchronous

 I have open 1 connection which is close only when I close program. Can I use this connection ?
0
Comment
Question by:dvplayltd
  • 4
  • 3
7 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 24753195
0
 

Author Comment

by:dvplayltd
ID: 24754303
Thank you very much for you blog :-)

So look simple, if I do not interest when function will be end I simple call
mcmEmployees.BeginExecuteReader(Nothing, Nothing)

right ?

By the way, I do this due to slow internet. Record which I will save in this way are record for save user activites.
WHat is you option, is is good idea to use this  ?   I'm sure that for let say 0.5 sec. user can not do other action and for this time Asuncnosius operation will be ended. Even in case in 0.1 % of all record in which is not save this it is not so big problem, as long I do not have problem with other work.


Aaa. In call back I see that you close this command object . If I not have call back at all will I have problem if I not close this command ? For next operation same command will be created with New and I think that I will not have problem with this. What you will say ?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24754567
>>If I not have call back at all will I have problem

How will you know that your command succeeded?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:dvplayltd
ID: 24755277
I will not know ..but I do not need to know. Command will insert record and in 99.99 % will be OK, for other 0.01 % .. i do not care.
Reason to fail this record can be only 1 - connection is broken (this is possibe as my connection is via Interet to SQL Server) , and all other action wil stop at all, so with sure only 1 last user action will not be saved.

 I have second system for log which are independant from this for which I ask for, this is one more reason to not care for this 0.01 % in which I can not have record.

This save will be on every almost any user action like open form, close form (menu), commit specific action , search record .. too many cases to make user to wait for this. I want to make record for user action, but want to pay this hight price for this :-)

By the way .. i use MARS. Hyyym. With 3 user server show me that I have open 15 connection, I think that this is due to MARS. I'm interesting this MARS are count like separate connection, or not ? This question is connected with needed license about number connection to SQL Server.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24755522
have a look at http://msdn.microsoft.com/en-us/library/ms379553(VS.80).aspx.

you should always handle the callback to close your command.

Licensing is very complex. There are so many variations. Do you have a site license or per processor license or a per seat license or ... ?

0
 

Author Comment

by:dvplayltd
ID: 24755803
My license will be per processor.
But I'm interesting if it was on CAL, than ??

Other - more importnat> I read deeply this new link from you, thank you.
Hyym. it say that connection thah have async=true take more time.

Execution of synchronous operations on connections that have asynchronous operations enabled will have noticeably increased resource utilization.

In cases where you need both synchronous and asynchronous APIs, you should use different connections if possible. If that's not an option, then you can still use the synchronous methods in connections opened with async=true, and they'll behave as usual; you'll see a small performance degradation, though.

Hyyym. How much slow will be all operation ? I think that will be minimal at I final I will have better perfonamce .. what is you option ?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24755945
>>How much slow will be all operation ?

I don't know.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now