hi all
i have c# class which calls a stored procedure having insert,update and delete method (using if to switch between them).
when i call the SP to EXECUTENONQUER() there is no response from the sqlserver. I too tested the stored proc seperately , it shows NO ROWS AFFECTED and 0 ROWS RETURNED. But the rows get inserted , or updated according to my call.(i found this by checking recs in table).what would be the trouble?? really confusing me.
below is my stored proc .
C# connectivity code: -
sqlCon = new SqlConnection(strCon);
-
sqlCmd = new SqlCommand();
-
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
-
sqlCmd.CommandText = "[SP Name]";
-
sqlCmd.Connection = sqlCon;
-
if (sqlCon.State == ConnectionState.Closed)
-
sqlCon.Open();
-
int result = sqlCmd.ExecuteNonQuery();
-
stored procedure -
ALTER PROCEDURE SP_insertUserMaster
-
(
-
@UserName nvarchar(30),
-
@LoginId nvarchar(50),
-
@Password nvarchar(80),
-
@SecurityLevel int,
-
@Department nvarchar(15),
-
@TP nchar(1))
-
-
AS
-
SET NOCOUNT ON
-
if @TP='I'
-
BEGIN
-
DECLARE @nCnt NUMERIC
-
SELECT @nCnt=(select count(*) from UserMaster Where LoginId=@LoginId)
-
IF @nCnt<=0
-
begin
-
INSERT INTO UserMaster
-
(UserName, LoginId, Password, SecurityLevel, Department)
-
VALUES
-
(@UserName,@LoginId,@Password,@SecurityLevel,@Department)
-
end
-
-
END
-
return
-
-
-
thanku
-
-
-
3 3016
hi ck
i am new to sqlserver, can u tell in detail to rectify my trouble.
thank u
ssk
hi ck
i am new to sqlserver, can u tell in detail to rectify my trouble.
thank u
ssk
am not sure how c# works. but in ASP, you can execute stored proc and can return resultset. the following query can work in ASP. try it in c#. test it first. -
ALTER PROCEDURE SP_insertUserMaster
-
(
-
@UserName nvarchar(30),
-
@LoginId nvarchar(50),
-
@Password nvarchar(80),
-
@SecurityLevel int,
-
@Department nvarchar(15),
-
@TP nchar(1))
-
-
AS
-
SET NOCOUNT ON
-
if @TP='I'
-
BEGIN
-
DECLARE @rCnt int
-
-
if not exists(select 1 from UserMaster Where LoginId=@LoginId)
-
begin
-
INSERT INTO UserMaster
-
(UserName, LoginId, Password, SecurityLevel, Department)
-
VALUES
-
(@UserName,@LoginId,@Password,@SecurityLevel,@Department)
-
-
select @@rowcount
-
return1/9/2008
-
end
-
-
END
-
-
also, this will only return value if the loginid is not yet in usermaster.try passing a loginid that you know not existing yet...
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RotterdamStudents |
last post by:
Hello there,
i have a strange problem. I can't get php to insert multiple rows at once in
a MySQL database. I use the
$sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d',...
|
by: Savas Ates |
last post by:
My Stored
*********************************************************
CREATE PROCEDURE st_seconddegree
@fromwhom numeric(18), @towhom numeric(18) AS
if not exists (select 1 from crosstable where...
|
by: Gnurp Gnarp |
last post by:
When the number of columns get large, it becomes increasingly
difficult to view the results of a select in a small window (e.g. 80
line xterm) because of line wrapping. Can I have the results of...
|
by: dkode8 |
last post by:
Heres my problem, the first part selects a row from the database, if
there is no row with the criteria it inserts a row and then returns it,
the problem is the IF statement that inserts the row,...
|
by: manning_news |
last post by:
Using SQL2000. According to Books Online, the avg aggregrate function
ignores null values. ((3+3+3+3+Null)/5) predictably returns Null. Is
there a function to ignore the Null entry, adjust the...
|
by: Richard G |
last post by:
I'm a database guy, so go easy on me here. :) How can I get the rowcount
of the affected rows of a SQL statement from a stored procedure call? I
know that "set nocount on" does not return the...
|
by: kenfar |
last post by:
I've got a batch etl process in which I typically wrap DML with selects
in order to capture the number of rows affected. For example:
SELECT 'rows updated', COUNT(*)
FROM NEW TABLE
( UPDATE...
|
by: Dave |
last post by:
I'm in need of a little sql help.
How do i get a list of ids from one table that do not have the same ids in
another table?
I hope that makes sense.
|
by: TG |
last post by:
Hi!
Once again I have hit a brick wall here. I have a combobox in which
the user types the server name and then clicks on button 'CONNECT' to
populate the next combobox which contains all the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |