Click here to Skip to main content
Rate this: bad
good
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
good
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.
//C#
try
  {
     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 */
     sqlConnection.Open();
     return command.ExecuteNonQuery();
     sqlConnection.Close();
  }
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[^]
  Permalink  
v2
Comments
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 Sergey Alexandrovich Kryukov 470
1 Gihan Liyanage 317
2 ClimerChinna 182
3 vikinghunter 176
4 OriginalGriff 141
0 Sergey Alexandrovich Kryukov 8,653
1 OriginalGriff 7,132
2 CPallini 2,598
3 Richard MacCutchan 2,060
4 Abhinav S 1,808


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2014
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