Click here to Skip to main content
13,046,562 members (72,315 online)
Rate this:
Please Sign up or sign in to vote.
hi all,
Can i bind data grid view with sql procedure in my procedure i want to use only cursor
on any table...
how to use please....
thanks in advance
Posted 15-Oct-12 2:20am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

for more detail on your procedure writing please refer this link
Sql Server - How to write a Stored procedure in Sql server[^]

and you can simply call your procedure using this type c# code.
     sqlConnection = new SqlConnection(dbConnectionString);
     SqlCommand command = new SqlCommand("Your procedure name", sqlConnection);
     command.CommandType = CommandType.StoredProcedure;
     /* If your procedure acepting parameter then pass parameter value like this...
      also you need to pass proper data type here i use 'SqlDbType.VarChar', but you need to modify based on your parameter type.
     command.Parameters.Add("@PARAMNAME1", SqlDbType.VarChar).Value = "YOUR VALUE" //like this  txtFirstName.Text;
     command.Parameters.Add("@PARAMNAME2", SqlDbType.VarChar).Value = "YOUR VALUE" //like this  txtLastName.Text;
/* now all set, so open your database connection and execute your command over database */
     return command.ExecuteNonQuery();
catch (SqlException ex)
     Console.WriteLine("SQL Error" + ex.Message.ToString());
     return 0;

or for more detail on this please refer this link...

Create CLR Stored Procedure with Visual Studio Express Edition[^]
9783444184 16-Oct-12 0:27am
how to bind in data grid view if i am using cursor in my procedure.
Tejas Vaishnav 17-Oct-12 3:59am
cursor will return row then your procedure will also return that data, so you can directly use that data to fill your data table or data set to bind with your grid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100