Solved

Asynchronous send command to SQL Server with ADO.NET

Posted on 2009-07-01
7
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 70

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 70

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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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 70

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 70

Expert Comment

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

I don't know.
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

738 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