SqlDataAdapter missing rows?

Posted on 2009-05-26
Medium Priority
Last Modified: 2012-05-07
I wrote a stored procedure in sql 2005 that returns 14 rows when I run it directly from management studio.  When I call the same stored procedure from .net with the same parameter, it returns 13 rows.   I'm using SqlDataAdapter and have never had a problem like this with it before.  Any suggestions?  Nothing stands out with the one missing row.  It's pretty much in the middle of the dataset with simliar data as the rest of the rows (but different enough to not be excluded in a SELECT DISTINCT).
sqlConnection = new SqlConnection(SQLCONNECTIONSTR);
            DataTable dtOrderData = new DataTable();
            SqlCommand cmd = new SqlCommand("TestingSTP", sqlConnection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Parameter1", SqlDbType.Int).Value = cartData.ClientID;
            SqlDataAdapter da = new SqlDataAdapter(cmd);

Open in new window

Question by:collages
  • 2
LVL 28

Expert Comment

ID: 24474031
I would recommend either debugging and stepping through the code you posted. Make sure the values you are passing to the stored procedure are what you expect. Also execute the stored procedure through management studio (NOT just the SQL statement in the stored procedure).

You can alternatively set up a SQL trace and see what is being received and returned, but your user may need special permissions on the db.

Remember, don't assume, VERIFY.

Author Comment

ID: 24474500
I tried a sql trace and it didnt reveal anything I didn't know.   I also tried stepping through the .net debugger and everything was correct, except that the row count for the datatable was 13, whereas the rows returned in management studio was 14.

Accepted Solution

collages earned 0 total points
ID: 24474626
I tracked the problem down.  A stp was being run later in the c# code that affected the table.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

624 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