Use a cursor from the page

i want to call a cursor froom the aspx.cs page

Please give a demo of corsor and how I will use it from the PAGE of ASP.NET 2.0 (CODE BEHIND)
jyotiramanAsked:
Who is Participating?
 
Om PrakashConnect With a Mentor Commented:
Instead of cursor you can query database and loop through in c#
 string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
    SqlConnection myConnection = new SqlConnection(myConnString);
    SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
    myConnection.Open();
    SqlDataReader myReader;
    myReader = myCommand.ExecuteReader();
    // Always call Read before accessing data.
    while (myReader.Read()) {
       Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
    }
    // always call Close when done reading.
    myReader.Close();
    // Close the connection when done with it.
    myConnection.Close();

Open in new window

0
 
darshan_derasariConnect With a Mentor Commented:
Look at the sample code provided for cursor in below links. You can define your necessary code for cursor in stored procedure and call it from the code behind of your web page.

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=141

http://www.mssqltips.com/tip.asp?tip=1599

0
All Courses

From novice to tech pro — start learning today.