用sql过程绑定数据网格 [英] bind data grid with sql procedure

查看:68
本文介绍了用sql过程绑定数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我可以在我的过程中仅使用游标
将数据网格视图与sql过程绑定在一起吗? 在任何桌子上...
请如何使用....
在此先感谢

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

推荐答案

有关过程编写的更多详细信息,请参考此链接
Sql Server-如何在SQL服务器 [
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;
  }



或对此有更多详细信息,请参阅此链接...

使用Visual Studio Express Edition创建CLR存储过程 [ ^ ]



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

Create CLR Stored Procedure with Visual Studio Express Edition[^]


这篇关于用sql过程绑定数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆