?
Solved

Asynchronous send command to SQL Server with ADO.NET

Posted on 2009-07-01
7
Medium Priority
?
274 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 2000 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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