Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 stored procedure not able to insert rows

Author  Topic 

mrkcse
Starting Member

2 Posts

Posted - 2008-09-06 : 03:09:43
Iam writing the following procedure for inserting phone call details into sqlserver.Iam using c# language on aspnet2.0 platform. In the debugging the code everything is fine and showing that record has inserted through procedure and cmd.ExecuteNonqQuery also returning value 1 each time.
While accessing sqlserver phonecalls table it is not showing any records which are inserted.previosly this application was running fine and now also procedure running fine.dont know what the problem is.Here is the procedure...help me

CREATE PROCEDURE [dbo].[Ph_Insert]

@Extension char(10),

@CallDate datetime,

@CallTime Datetime,

@Phone char(20),

@Duration smallmoney,

@Trunk int,

@calls int,

@CallType char(20),

@cost smallmoney

AS

declare @type char(1)

IF @CallType = 'Inc Call'

SET @type = 'I'

ELSE IF @CallType = 'Missed Call'

SET @type = 'M'

ELSE SET @type = 'O'

select * from PhoneCalls where Extension = @Extension and CallDate = @CallDate and CallTime = @CallTime

IF @@rowcount = 0

BEGIN

INSERT INTO PhoneCalls

(

Extension,

CallDate,

CallTime,

Phone,

Duration,

Trunk,

calls,

CallType,

Flag,

InsertedOn,

DtandTime

)

VALUES

(

@Extension,

@CallDate,

@CallTime,

@Phone,

@Duration,

@Trunk,

@calls,

@cost,

@CallType,

@type,

Getdate(),

convert(char(11),@CallDate,106) + ' ' + convert(char(10),@CallTime,108)


)

END

ELSE

BEGIN

UPDATE PhoneCalls SET

Extension = @Extension,

CallDate = @CallDate,

CallTime = @CallTime,

Phone = @Phone,

Duration = @Duration,

Trunk = @Trunk,

calls = @calls,

cost = @cost,

CallType = @CallType,

Flag = @type,

UpdatedOn = GetDate(),

DtandTime = convert(char(11),@CallDate,106) + ' ' + convert(char(10),@CallTime,108)

WHERE Extension = @Extension and

CallDate = @CallDate and

CallTime = @CallTime

END







mrkcse
Starting Member

2 Posts

Posted - 2008-09-06 : 03:25:30
Is there any way to forcefully insert records using stored procedure?
Go to Top of Page
   

- Advertisement -