3
Answers

Executing a select statement in visual studio???

Zimbini Walaza

Zimbini Walaza

16y
5.5k
1

i created a stored procrdure that checks for duplicates in a database when importing data from a spreadsheet.When i try to execute the SP in visual studio using ExecuteNonQuiry() it throws an error that says executeNonQuiry does not execute select statements.

Is there any  other way for me to execute this quiry.plz help.Here is the stored procedure

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE [dbo].[ChkDup]

@StudentID nvarchar(50),

@ModuleCode nvarchar(50)

AS

if exists(SELECT COUNT(StudentID),COUNT(ModuleCode)

FROM StudentID

Group By StudentID

HAVING COUNT(StudentID) < 1 AND COUNT(ModuleCode) < 1)

INSERT INTO StudentModule(StudentID,ModuleCode)

VALUES(@StudentID,@ModuleCode)

Answers (3)