I'm writing a VB6 app which calls several stored procedures on my SQL
Server DB.
The first stored procedure must complete its inserts before the second
stored procedure can query the modified table for its results. My
problem is that
the second stored procedure occasionally returns a different result
set, acting as if the first stored procedure didn't complete (or
didn't run).
So how do I ensure (or test/poll?) that the first stored procedure
runs to completion before returning control back to my VB app?
Thanks in advance,
Ralph 9 5487 cr*******@hotma il.com (Ralph Cramden) wrote in
news:e2******** *************** ***@posting.goo gle.com: I'm writing a VB6 app which calls several stored procedures on my SQL Server DB.
The first stored procedure must complete its inserts before the second stored procedure can query the modified table for its results. My problem is that the second stored procedure occasionally returns a different result set, acting as if the first stored procedure didn't complete (or didn't run).
So how do I ensure (or test/poll?) that the first stored procedure runs to completion before returning control back to my VB app?
Thanks in advance,
Ralph
Might it make sense to combine your procedures? Or perhaps create a third
stored procedure that calls the first then the second in sequence?
[posted and mailed, please reply in news]
Ralph Cramden (cr*******@hotm ail.com) writes: I'm writing a VB6 app which calls several stored procedures on my SQL Server DB.
The first stored procedure must complete its inserts before the second stored procedure can query the modified table for its results. My problem is that the second stored procedure occasionally returns a different result set, acting as if the first stored procedure didn't complete (or didn't run).
So how do I ensure (or test/poll?) that the first stored procedure runs to completion before returning control back to my VB app?
Do you call the procedures from different threads or asynchronously? That
would be the only way for the second procedure before the first have
completed. In both cases, you would need synchronization in the client
code.
I suspect that your real problem is something else. That is, you are calling
the two procedures sequentially from the same thread, but there is some
flaw of logic, causing the incorrect result. It could also be that the
first procedure runs into an error condition, which you fail to handle
properly in the application code.
That is, if you are calling stored procedures in the plain vanilla way,
you don't have to worry about synchronization , since all calls to SQL
Server are synchronous.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
My fear is that I'm calling the stored procedures asynchronously
and I don't want to.
The Project properties dialog box shows that the app is a standard
EXE project type (threading model is grayed out (so I'm assuming
a single thread)).
The SQL server though is a multiple CPU(4) platform would that
make a difference?
How would I synchronize the client code?
Erland Sommarskog <es****@sommars kog.se> wrote in message news:<Xn******* *************** @127.0.0.1>... [posted and mailed, please reply in news]
Do you call the procedures from different threads or asynchronously? That would be the only way for the second procedure before the first have completed. In both cases, you would need synchronization in the client code.
I suspect that your real problem is something else. That is, you are calling the two procedures sequentially from the same thread, but there is some flaw of logic, causing the incorrect result. It could also be that the first procedure runs into an error condition, which you fail to handle properly in the application code.
That is, if you are calling stored procedures in the plain vanilla way, you don't have to worry about synchronization , since all calls to SQL Server are synchronous.
Ralph Cramden (cr*******@hotm ail.com) writes: My fear is that I'm calling the stored procedures asynchronously and I don't want to.
I don't want to scorn you, but if you don't know if you are writing
a synchronous application or not, you are a very confused VB programmer.
(And if you really want certainty, you would have to ask in a Visual
Basic newsgroup; that's not really an SQL Server question.)
The SQL server though is a multiple CPU(4) platform would that make a difference?
That has nothing to do with it.
How would I synchronize the client code?
It does not sound like you would need to. If your code looks like this:
Set cmd = new ADODB.Command
cmd.ActiveConne ction = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = my_first_proc
cmd.Execute
Set cmd = Nothing
Set cmd = new ADODB.Command
cmd.ActiveConne ction = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = my_second_proc
cmd.Execute
Set cmd = Nothing
There is nothing to synchronize. cmd.Execute blocks until SQL Server
has completed execution.
If you are using separate threads, or the synchronous capabilities of
ADO and issue the commands on two separate connection, you have indeed
quite a few interesting problems. Then again, that's not a path you
should not take if you don't know what you are doing.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
A DTS package would do this for you really easily.
Ryan (ry********@hot mail.com) writes: A DTS package would do this for you really easily.
Eh? I don't know much about DTS, but there is actually one thing I've
used DTS for, and that is to test the multi-threading capabilities of a
Perl module for SQL Server access. Because in DTS, things really happens
in parallel. What implications that has for what DTS is used for, I don't
really know, but I have noticed that you can arrange tasks, so that task B
does not start before task A has completed, but you can also arrange for
A and B to be in parallel if you like.
Now, whether this has any relevance for Ralph's question, I don't know,
but my guess it has not.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Erland,
My understanding of the problem was that there was a need to run two
SP's. The second SP needs to run after the first has completed. Doing
this in a series of stored procedures or an SP that runs both could
force the execution plan to determine that it's better to run the second
SP before the first (hence the problem).
I was suggesting the DTS as an option as you can make a stored procedure
'wait' until the sucess of a prior SP. In it's most simplistic terms,
this should solve the problem. It is really good at running things in
parallel as well, but this may work in this case.
I would have tried creating a small DTS package that runs the second SP
on success of the first task. This would take a matter of minutes to do
and would not require changing the SP's.
I may well be wrong, but given that it would take a short time to set up
and test, I felt it might be worth a look. Hopefully I have not missed
the point.
Ryan
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Ryan (an*******@devd ex.com) writes: My understanding of the problem was that there was a need to run two SP's. The second SP needs to run after the first has completed. Doing this in a series of stored procedures or an SP that runs both could force the execution plan to determine that it's better to run the second SP before the first (hence the problem).
I was suggesting the DTS as an option as you can make a stored procedure 'wait' until the sucess of a prior SP. In it's most simplistic terms, this should solve the problem. It is really good at running things in parallel as well, but this may work in this case.
That's correct, that DTS gives you a synchronization mechanism. (Hey,
that is as much I know about DTS.)
However, you can achieve the same with:
Set cmd = new ADODB.Command
cmd.ActiveConne ction = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = my_first_proc
cmd.Execute
Set cmd = Nothing
Set cmd = new ADODB.Command
cmd.ActiveConne ction = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = my_second_proc
cmd.Execute
Set cmd = Nothing
Throwing in DTS in a VB app to solve something which works out of the
box in VB appears to be a huge overkill to me.
(And if your VB app is multi-threaded or you use asynchronous calls,
DTS would still be a huge overkill, give that implmentation of
thread-synchronization or handling of asynchronous calls is not really
rocket science, even if it goes beyond what a plain-vanilla does.)
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Fair enough :-)
Erland Sommarskog <es****@sommars kog.se> wrote in message news:<Xn******* *************** @127.0.0.1>... Ryan (an*******@devd ex.com) writes: My understanding of the problem was that there was a need to run two SP's. The second SP needs to run after the first has completed. Doing this in a series of stored procedures or an SP that runs both could force the execution plan to determine that it's better to run the second SP before the first (hence the problem).
I was suggesting the DTS as an option as you can make a stored procedure 'wait' until the sucess of a prior SP. In it's most simplistic terms, this should solve the problem. It is really good at running things in parallel as well, but this may work in this case.
That's correct, that DTS gives you a synchronization mechanism. (Hey, that is as much I know about DTS.)
However, you can achieve the same with:
Set cmd = new ADODB.Command cmd.ActiveConne ction = cnn cmd.CommandType = adCmdStoredProc cmd.CommandText = my_first_proc cmd.Execute Set cmd = Nothing Set cmd = new ADODB.Command cmd.ActiveConne ction = cnn cmd.CommandType = adCmdStoredProc cmd.CommandText = my_second_proc cmd.Execute Set cmd = Nothing
Throwing in DTS in a VB app to solve something which works out of the box in VB appears to be a huge overkill to me.
(And if your VB app is multi-threaded or you use asynchronous calls, DTS would still be a huge overkill, give that implmentation of thread-synchronization or handling of asynchronous calls is not really rocket science, even if it goes beyond what a plain-vanilla does.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: SQLServer007 |
last post by:
25 more days until the "get it free" promotion runs out for xSQL
Object (you can get it from http://www.x-sql.com)
Here are just some of the great features packed in the product:
- Compare SQL Server objects (databases, tables, views, stored
procedures, user defined data functions etc.) accross servers.
- view and print dependencies;
- generate color coded scripts for any object in the database or many
of them at once (many configurable...
|
by: jrefactors |
last post by:
I want to know the differences between SQL Server 2000 stored
procedures and oracle stored procedures? Do they have different
syntax? The concept should be the same that the stored procedures
execute in the database server with better performance?
Please advise good references for Oracle stored procedures also.
thanks!!
|
by: scott |
last post by:
Hi,
Just wondering what sort of problems and advantages people have found using
stored procedures. I have an app developed in VB6 & VB.NET and our
developers are starting to re-write some of the code in stored procedures
(im advocating encryption of them). When deploying an application however
stored procedure seem to add another level of complexity to installation. In
future we also plan to have an basic ASP app with some of the...
|
by: Kent Lewandowski |
last post by:
hi all,
Recently I wrote some stored procedures using java jdbc code
(admittedly my first stab) and then tried to implement the same within
java packages (for code reuse). I encountered problems doing this.
I wanted to implemented a generic "Helper" class like this:
/**
* Helper
|
by: Tim Marshall |
last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with
interest and on reading the post describing Lauren Quantrell's
SmartTree, I've run into something I don't understand: Stored
Procedures. I thought stored pricedures were an Oracle/MS SQL Server
thing and don't know how they work with Access Jet. I've looked at some
of the help on stored procedures in A2003, but really don't understand
what's going on.
Can someone...
| |
by: John |
last post by:
Hi
When developing vb.bet winform apps bound to sql server datasource, is it
preferable to use SELECTs or stored procedure to read and write data from/to
SQL Server? Why?
Thanks
Regards
|
by: mooreit |
last post by:
The purpose for my questions is accessing these technologies from
applications. I develop both applications and databases. Working with
Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test
Environments.
What is the purpose of a view if I can just copy the vode from a view
and put it into a stored procedure?
Should I be accessing views from stored procedures?
|
by: javelin |
last post by:
Can someone recommend a utility (preferably open-source) to
synchronize changes across servers? I need to bring only data over in
some cases, and only objects in other cases. Any ideas?
Thx!
|
by: peter |
last post by:
I am trying to get a SQL stored procedure to use user maintained MQT
implicitly which raises questions on when they are used or not used.
In theory you would expect the stored procedure to pick up the MQT at
the time it is bound on the creation of the static SQL. This raises
the question on how you stop it or start it using a MQT as there is no
option on the bind. What happens when it is rebound? What happens if
the plan is made invalid...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |