Click here to Skip to main content
11,583,859 members (48,219 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET DataGridView
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 at 16-Oct-12 0:27am
how to bind in data grid view if i am using cursor in my procedure.
Tejas Vaishnav at 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
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 314
2 virusstorm 268
3 Richard Deeming 220
4 Dave Kreskowiak 200
0 OriginalGriff 1,623
1 Sergey Alexandrovich Kryukov 1,135
2 Abhinav S 701
3 Dave Kreskowiak 627
4 Suvendu Shekhar Giri 568

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2015
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