Filling a DataTable causing RowState to change in another table

M

michael

I have 2 separate DataTables in a DataSet. These tables are in no way related
to one anohter with Relations.

When I Fill one table, it causes a row's RowState in the other table to
change from Unchanged to Modified. In the absence of editing the row! Can
anyone think of ways to figure out what might be causing this?
 
W

William Vaughn

The Fill method handles multiple resultsets. If more than one rowset is
returned, it posts the rows (the changes) to more than one DataTable.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
M

michael

Could you please indulge me and expand on your answer? When you say more than
one resultset, do you mean that there's more than one Select being executed
and those rows are placed in a different table?
 
W

William Vaughn

Precisely. Any SQL Server query can contain more than one SELECT as can
stored procedures.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
michael said:
Could you please indulge me and expand on your answer? When you say more
than
one resultset, do you mean that there's more than one Select being
executed
and those rows are placed in a different table?
 
M

michael

OK. I'm on to something here. However, I'm sure that the StoredProcedure
that is being executed has only one SELECT being run. And, in addition, the
"other" table that is experiencing the unexpected "Modified" is completely
different than the table which is actually being filled. Rows from the first
table wouldn't "fit" into the second table. So, I'm still puzzled.

I included the StoredProcedure that gets fired. It's not really all that
complicated and each return identical columns. And, only one ResultSet should
be returned with each execution.

IF @PNumber=-1
BEGIN
SELECT P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number], COUNT(S1.[Service Record Number]) AS [Count of
Services]
FROM Patients AS P LEFT OUTER JOIN
Service AS S1 ON P.[Medical Record Number] = S1.[Medical Record
Number] AND P.[Billing Number] = S1.[Billing Number]
GROUP BY P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number]
HAVING (P.[Current Location] LIKE @Unit)
ORDER BY P.[Current Location], P.[Full Name]

END
ELSE
BEGIN
SELECT P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number], COUNT(S1.[Service Record Number]) AS [Count of
Services]
FROM Patients AS P LEFT OUTER JOIN
Service AS S1 ON P.[Medical Record Number] = S1.[Medical Record
Number] AND P.[Billing Number] = S1.[Billing Number]
WHERE S1.[Service Provider]=@ProviderNumber
GROUP BY P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number]
HAVING (P.[Current Location] LIKE @Unit)
ORDER BY P.[Current Location], P.[Full Name]
END

END
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top