如何在C#中调用Store过程 [英] How to call Store procedure in C#

查看:289
本文介绍了如何在C#中调用Store过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个名为sp_ManpowerCollection_BacNDelete的存储过程

如何在C#代码中调用该过程。我用一种方法来连接数据库。方法如下:



I have created a store procedure named "sp_ManpowerCollection_BacNDelete"
How can I call the procedure in C# code. I use a method to connect database. The method is as following :

public void DBConnection(string strDBName)
        {
            try
            {
                if (IDisconnection != null)
                {
                    if (IDisconnection.State == System.Data.ConnectionState.Open)
                    {
                        IDisconnection.Close();
                    }
                    IDisconnection = null;
                    IDisconnection = new SqlConnection();
                }
                else
                {
                    
                    IDisconnection = new SqlConnection();
                }
                

                strConnectionString = "Data Source=localhost;Initial Catalog=" + strDBName + ";User ID=sa;Password=sa1234";
                IDisconnection.ConnectionString = strConnectionString;
                IDisconnection.Open();
                mblnTransactionStart = false;
            }
              
            catch (System.Data.SqlClient.SqlException e1)
            {
                throw (e1);
            }
            catch (System.Exception ex)
            {                
                throw ex;                
            }
            finally
            {
            }
        }

推荐答案

下面链接提供了很好的教程。



http://csharp-station.com/Tutorial/AdoDotNet/Lesson07 [ ^ ]
There is good tutorial available at below link.

http://csharp-station.com/Tutorial/AdoDotNet/Lesson07[^]


如何在asp.net c#代码中调用存储过程 [ ^ ]



问候....:)
how to call stored procedure in asp.net c# code[^]

regards....:)


这篇关于如何在C#中调用Store过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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