Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2017
    Posts
    197
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Visual Studio Executing Stored Procedure

    In sql server I have a file called truncate.sql containing
    Code:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author:		<Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:	<Description,,>
    -- =============================================
    CREATE PROCEDURE TruncateTableA
    	
    AS
    BEGIN
    	truncate table tableA;
    END
    GO
    I want to execute the stored procedure but throws exception, Could not find stored procedure TruncateTableA.
    Code:
    SqlCommand truncateTableA = new SqlCommand("TruncateTableA", Connection);
    truncateTableA.CommandType = CommandType.StoredProcedure;
    Connection.Open();
    TruncateReader = truncateTableA.ExecuteReader();
    What do I put in the command to execute the stored Procedure TruncateTableA?

  2. #2
    Regular Coder
    Join Date
    Aug 2017
    Posts
    197
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Solved. Query->Parse, Query Execute creates SP. ExecuteReader() can't execute a SP if its not created yet.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •