Saturday, March 24, 2012

Why recordset going to second table in dataset?

I am using the Enterprise library and did an executedataset to retrieve
results into a dataset. I noticed that the result went into the second
table in the table collection of the dataset instead of the first table.
ds.Tables[0].Rows.count = 0 <-- why?
while
ds.Tables[1].Rows.count had the number of rows expected.
Is there a reason for this behaviour?
John DalbergThere might be a select statement (in your sql) somewhere above that
which is returning the rows. If not, I don't know the answer.
John Dalberg wrote:
> I am using the Enterprise library and did an executedataset to
> retrieve results into a dataset. I noticed that the result went into
> the second table in the table collection of the dataset instead of
> the first table.
> ds.Tables[0].Rows.count = 0 <-- why?
> while
> ds.Tables[1].Rows.count had the number of rows expected.
> Is there a reason for this behaviour?
> John Dalberg
Are you using a SQL Server stored procedure? If so, did you remember to use
"SET NOCOUNT ON" in the procedure to suppress the informational "x rows were
affected" messages that are sent as resultsets?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
"Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote:
> John Dalberg wrote:
> Are you using a SQL Server stored procedure? If so, did you remember to
> use "SET NOCOUNT ON" in the procedure to suppress the informational "x
> rows were affected" messages that are sent as resultsets?
The sp was created using VS2003 using the dataadaptor designer. Yes there's
a 'set no nocount on' statement which was put by vs2003. All the sp does is
a select using a join between two tables.
When I run the sp in the query analyzer, I only see a single row which is
expected. I am posting the sp below.
CREATE PROCEDURE dbo.GetCustomers
AS
SET NOCOUNT ON;
SELECT Customer.CustName, Contact.ContactName FROM Customer CROSS JOIN
Contact GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

0 comments:

Post a Comment