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 ONGO
SET
QUOTED_IDENTIFIER ONGO
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)
Zimbini WalazaPosted Sep 2, 2008, 6:13 PM
my problem is i don't know how to call it.Any suggestions?
Mahesh ChandPosted Sep 2, 2008, 3:23 AM
You need to use ExecuteReader, not ExecuteNonQuery if you are selecting data.
OR try SqlDataAdapter.Fill method. Search this site for sample code.
Blocked AccountPosted Sep 2, 2008, 12:02 AM
Hi,
ExecuteNonQuery method is used for :
1. Sending SQL Insert statements to a database.
2. Sending SQL Update statements to a database.
3. Sending SQL Delete statements to a database.
i did not know how u are calling the sp in your code.