473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Loading a datagrid/datalist from a Stored procedure that uses cursor

In my datagrid, I call my SP and if I only have a simple select statement, everything comes back fine and all rows get displayed in datagrid using datasource and databind

But if I use a cursor inside the SP (to manipulate data), the data that comes out of the SP can not be displayed in the datagrid. In this case only the first row shows up
Here is aportion of my page_load

System.Data.SqlClient.SqlCommand cm;
System.Data.SqlClient.SqlDataReader dr = null;
System.Data.SqlClient.SqlCommand cm;
//DataSet ds = new DataSet();

cm = new System.Data.SqlClient.SqlCommand();
cm.Connection = ConnectionString;
cm.Connection.Open();
cm.CommandType = System.Data.CommandType.StoredProcedure;
cm.CommandText = "[getTransList]";

dr = cm.ExecuteReader();
gridListData.DataSource=dr;
gridListData.DataBind();
dr.Close();
Nov 15 '05 #1
1 2269
Hi,

Binding the DataGrid to a DataReader is not a good idea. You should create
and populate a DataSet or a DataTable and then bind the grid to those.

Second, ensure you return a valid rowset from your SP. I have little
experience with cursors, but I suppose you should still execute a SELECT
statement to return the rowset after you have finished data manipulation.
You could probably introduce a temp table or a local variable of type TABLE
(given your DB is SQL Server 2000).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Merdaad" <an*******@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
In my datagrid, I call my SP and if I only have a simple select statement, everything comes back fine and all rows get displayed in datagrid using
datasource and databind.
But if I use a cursor inside the SP (to manipulate data), the data that comes out of the SP can not be displayed in the datagrid. In this case only
the first row shows up! Here is aportion of my page_load:

System.Data.SqlClient.SqlCommand cm;
System.Data.SqlClient.SqlDataReader dr = null;
System.Data.SqlClient.SqlCommand cm;
//DataSet ds = new DataSet();

cm = new System.Data.SqlClient.SqlCommand();
cm.Connection = ConnectionString;
cm.Connection.Open();
cm.CommandType = System.Data.CommandType.StoredProcedure;
cm.CommandText = "[getTransList]";

dr = cm.ExecuteReader();
gridListData.DataSource=dr;
gridListData.DataBind();
dr.Close();


Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jarrod Morrison | last post by:
Hi All I have a stored procedure with a temporary table that with two columns in it. The first column contains 3 digit numbers and the second column some descriptive data. I was wondering what...
4
by: John | last post by:
Hi everyone, I have a stored procedure which I use to query a table. The first part of the stored procedure uses a cursor to update a temp table whilst the second part of the query actually...
5
by: mas | last post by:
I have a Stored Procedure (SP) that creates the data required for a report that I show on a web page. The SP does all the work and just returns back a results set that I dump in an ASP.NET...
0
by: volodymyr.sapiha | last post by:
I have stored procedure which have one input parameter - cursor. Is there any mechanism to pass parameter to this stored procedure with the help ADO.NET. Thank you.
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
1
by: peaceburn | last post by:
Hi, I'm gonna pull my hair in the coming days with these DB2 stored procedures. So the issue, let's assume a simple stored procedure like this : CREATE PROCEDURE MYSCHEMA.PROCEDURE1 ( )...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
1
by: mcasaurabhsumit | last post by:
differences between stored procedure and cursor
0
by: Chris Padian | last post by:
It must be possible to pass a cursor as an input parameter to a DB2 Stored Procedure. The cursor would point to a location of an array of, let's say, employee numbers to be passed and used to...
9
by: ookdeh | last post by:
Dear all, i'm facing a problem with my storedprocedure which happened when i ran my web application and reach to the point where my class invoke this storedprocedure, my SP contains a cursor...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.