Solved

Asynchronous send command to SQL Server with ADO.NET

Posted on 2009-07-01
7
269 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 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run time Error 4 47
Code works but it's slow 28 70
VB.NET - Error - Object not set in Module 4 33
RLDC Reporting in Visual studio 11 15
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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