Click here to Skip to main content
15,889,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :

C#
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
            {
            }
        }
Posted
Updated 8-Sep-13 23:34pm
v2

 
Share this answer
 
Comments
Sumon562 9-Sep-13 5:38am    
Thanks
Dholakiya Ankit 9-Sep-13 5:41am    
welcome :)
There is good tutorial available at below link.

http://csharp-station.com/Tutorial/AdoDotNet/Lesson07[^]
 
Share this answer
 
Comments
Sumon562 9-Sep-13 5:34am    
Thanks brother

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900