Wednesday, March 21, 2012
Problem populating table with a cursor from VB GUI
I have a store proc that that does various bits of data manipulation, but
the last part I have used a cursor to update 2 fields in a table. This sp i
s
called by a VB front end and then the contents of the table in question
displayed.
The problem is, if I run the sp directly (within VB's Server Explorer) these
2 fields are always fully populated. If however I call the sp from within
code in a GUI, after each call (which should fully populate the table based
on certain criteria) the 2 fields become less populated. What I mean by thi
s
is on the 1st call the 2 fields are 100% populated, with each subsequent cal
l
only populating maybe 50% of records, then 20%, until no records are
populated.
Would anyone have any ideas where I may look.
thanks"Chubbly Geezer" <ChubblyGeezer@.discussions.microsoft.com> wrote in message
news:1BE8A023-7631-49AA-85BC-E5FD5808EF00@.microsoft.com...
> Hi all
> I have a store proc that that does various bits of data manipulation, but
> the last part I have used a cursor to update 2 fields in a table. This sp
is
> called by a VB front end and then the contents of the table in question
> displayed.
> The problem is, if I run the sp directly (within VB's Server Explorer)
these
> 2 fields are always fully populated. If however I call the sp from within
> code in a GUI, after each call (which should fully populate the table
based
> on certain criteria) the 2 fields become less populated. What I mean by
this
> is on the 1st call the 2 fields are 100% populated, with each subsequent
call
> only populating maybe 50% of records, then 20%, until no records are
> populated.
> Would anyone have any ideas where I may look.
> thanks
If you post the code and any necessary DDL, we can give you a lot better
answer.
From the limited information you have provided, I would guess that your VB6
application may be timing out. Then again, without any idea of what is
really going on in the sproc, it's hard to say.
Rick Sawtell
MCT, MCSD, MCDBA
Friday, March 9, 2012
Problem is forming Query
I have a table
say SalesLeads. This table is accessed through various front -ends and
it stores data for Sales leads of various products.
This table has a reference to another table(SalesLeadRefTable)
Sample Data in SalesLeads
SalesLeadID Comments RefTableID
-----------------
1 Sample 1
Sample Data in SalesLeadRefTable
ReferenceID TableName TableFieldName
-----------------
1 ProductTable ProductID
I need to form a query which will refer to the refdtableID and form a
dynamic query like
Select Comments , TableName.TableFieldName from SalesLeads,TableName
Please let me know if this can be doen in 1 queryYou could implement a JOIN to one of many tables like this:
SELECT A.keycol, COALESCE(B.col1, C.col1, D.col1) AS col1
FROM Something AS A
LEFT JOIN Table1 AS B
ON A.keycol = B.keycol AND A.entity = 1
LEFT JOIN Table2 AS C
ON A.keycol = C.keycol AND A.entity = 2
LEFT JOIN Table3 AS D
ON A.keycol = D.keycol AND A.entity = 3
Otherwise you would have to use Dynamic SQL inside an EXEC statement.
--
David Portas
SQL Server MVP
--