That's an old concept for returning a value when actually no value can be returned (e.g. due to an error).
Here, you told the server that it must not count the rows affected. When you now ask "how many rows were affected" it cannot return the "correct" value, you ought to expect an exception, but for compatibility with legacy applications, it returns a number.
Any whole number from 0 to inifinite would pretend to be the correct result. Hence, the server must not return any value in that range. And therefore, it returns -1: it is not possible that a negative number of rows was affected.
Get used to that old concept, you may encounter it more often.
Ssql = " Select * from User_Access A Where A.User_pwd ='1234' "
set rs = Server.CreateObject("ADODB.RecordSet")
rs = DB.execute(Ssql,dbstatus)
If dbstatus <> 0 Then
'Error code here
Above is the code working ok . Actually this is written in dll. Now code will give error if "dbstatus" is other than 0 . Here I'm getting -1 always in my environment.
What a shocker. It is what the doc[^] says: For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command... For all other types of statements, the return value is -1
I want to know how can i increase the session existence time in SQL server. I have a software that uses a connection to SQL server . when it remains idle for some minutes then the new session will be created to SQL server from the application side . This produces me me a big problem . Because i use the connection_Id for auditing the user . in my login table i have applicationID that refers to connection_Id in sys.dm_exec_connections .
when the software authenticates the user , It updates the connection_ID in login table and through this column i can get my user's username in my triggers .
here is the problem
when my software becomes idle , then another connection_id is created and i can not trace my user because i can not reach my user in logins table
this is my login table
CREATE TABLE [dbo].[Logins](
[LoginUser] [nvarchar](50) NOT NULL ,
[Password] [nvarchar](50) NOT NULL,
[IsDefaultPassword] [int] NULL,
[AppID] [uniqueidentifier] NULL,
CONSTRAINT [PK_Logins] PRIMARY KEY CLUSTERED
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
and this is my authenticate procedure
CREATE PROCEDURE [dbo].[Authenticate] (@username nvarchar(30) , @password nvarchar(30))
declare @Authenticated intset @Authenticated = 0select @Authenticated = 1from Logins l
where l.LoginUser =@username and l.Password =@password
if @Authenticated = 1
declare @AppID uniqueidentifier
select @AppID=p.connection_id from sys.dm_exec_connections p
where p.session_id = @@SPID
set AppID = @AppID
where Logins.LoginUser = @username and Logins.Password = @password
select @Authenticated ,@AppID