April 7, 2009 at 3:11 pm
Hello all,
Im experiencing something I have never had an issue with.
I have a general insert update method. Below is a quick example of the code statements I am trying to execute.
DECLARE @EXISTS
a select statement that sets @EXISTS
IF @EXISTS = 1
BEGIN
UPDATE METHOD HERE
END
IF @EXISTS =0
BEGIN
INSERT METHOD HERE
END
Im not exactly sure what is happening, but I know the statements are being hit. I put a SELECT 1 in the @EXISTS =1 method and a SELECT 0 in the @EXISTS = 0 method.
I get the proper value back when I executescalar. 1 for update and 0 for insert.
Im at a complete loss here. If I execute the proc in management studio and pass in the exact same values, it runs fine and does exactly as it should. However, it runs from my aspx page and does nothing. Doesnt throw any errors.
Any help would be appreciated.
April 7, 2009 at 3:24 pm
Are you sure you are passing in a value - paraphrasing your procedure
CREATE PROC dbo.myproc
@Exists INT
AS
IF @EXISTS = 1
BEGIN
PRINT 'UPDATE METHOD HERE'
END
IF @EXISTS =0
BEGIN
PRINT 'INSERT METHOD HERE'
END
dbo.myproc NULL -- imitating passing of a NULL value ... nothing will happen and no error will be reported.
April 7, 2009 at 3:28 pm
ive checked and rechecked passed in values.
Im only passing in two ID's and four bit values from check boxes.
April 8, 2009 at 6:45 am
Use Sql Server Profiler and look what statement exactly passed to server to run.
If it wouldn't help, write here your stored procedure and the statement from Sql Server Profiler.
-------------------------
- Name?
- Abu Dalah Sarafi.
- Sex?
- 3 times a week!
- No, no. Male or Female?
- Male, female, sometimes camel...
April 8, 2009 at 8:19 am
Hi
Try using OUTPUT keyword to find out whther its updating any records or not.
CREATE TABLE EMPLOYEE_WORKING_HRS(
EMP_ID int NULL,
ENAME varchar(30) NULL,
YR varchar(4) NULL,
MON varchar(3) NULL,
WORKING_HRS int NULL,
RATE int NULL,
SALARY AS (WORKING_HRS*RATE)
)
INSERT INTO EMPLOYEE_WORKING_HRS VALUES(100,'SAM',2009,'JAN',176,100);
INSERT INTO EMPLOYEE_WORKING_HRS VALUES (101,'LIMO',2009,'JAN',176,110);
INSERT INTO EMPLOYEE_WORKING_HRS VALUES(102,'NAT',2009,'JAN',176,120);
INSERT INTO EMPLOYEE_WORKING_HRS VALUES (103,'BECK',2009,'JAN',176,130);
declare @Emp_ids table(ID int)
update EMPLOYEE_WORKING_HRS set RATE = RATE - 20
output inserted.EMP_ID into @Emp_ids
from EMPLOYEE_WORKING_HRS
WHERE RATE > 100
SELECT * FROM @Emp_ids
Modify the above code and see if your UPDATE statement is having any problems!!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply