显示标签为“sessions”的博文。显示所有博文
显示标签为“sessions”的博文。显示所有博文

2012年3月20日星期二

disconnection sessions

Hi,

Here is my code on how i connect to my database

Dim rst As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim vresponse As String
' On Error GoTo err_proc
Try
conn.Open(GetConn(getconnid))
Select Case getmode
Case 0 'execute then return first field
rst = conn.Execute(getsql)
If rst.EOF = False And rst.BOF = False Then
Try
vresponse = IIf(IsDBNull(rst.Fields.Item(0).Value), "", rst.Fields.Item(0).Value)
' vresponse = rst.Fields.Count
Catch ex As Exception
vresponse = "Error :" + ex.Message
End Try
End If
Case 1 'execute only
If bTransactional = True Then
conn.BeginTrans()
End If
conn.Execute(getsql)
vresponse = "OK"
If bTransactional = True Then
conn.CommitTrans()
End If
End Select

Return vresponse.Trim

* line 1)

rst = Nothing
conn = Nothing

Exit Function

supposed to be *line 1) terminates the connection/session form SQL server. But when i check to the SQL Query Analyzer, there is still some connections related to this command. So when i run again this commands, it creates another connection. How can i terminate/end my sessions in SQL.

Thanks

You can use KILL command, take a look at this link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_kf-kz_1zos.asp

2012年3月7日星期三

Disabling the identity column

I have a table that I want to disable the identity column that will be
disabled across different sessions. I cannot use SET IDENTITY_INSERT
table off as it does not persist across columns.
I also do not want to create a tmp table without the identity being
turned on, populate it and then rename the table as this seems a bit
time consuming on a large recordset.
Is there another way?
I will be using SQL server 2000 and/or ado.net
Thanks
Rippo
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!The only way is to drop the column.
AMB
"Rippo" wrote:

> I have a table that I want to disable the identity column that will be
> disabled across different sessions. I cannot use SET IDENTITY_INSERT
> table off as it does not persist across columns.
> I also do not want to create a tmp table without the identity being
> turned on, populate it and then rename the table as this seems a bit
> time consuming on a large recordset.
> Is there another way?
> I will be using SQL server 2000 and/or ado.net
> Thanks
> Rippo
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
>|||If you can't SET IDENTITY_INSERT for each session then you'll have to
use a non-identity column instead. Why are you using an IDENTITTY in
this situation? The point of an auto-generated surrogate key is that
you shouldn't care what value is inserted. If you want to control the
values externally then IDENTITY isn't the right solution.
--
David Portas
SQL Server MVP
--

2012年2月24日星期五

Disable triggers only for active sessions

Hey,

is it possible to disable all DML triggers for the current session only?
This is for manual data correction sessions where no trigger should be fired but all other user connection still should have active triggers.

Cheers,I don't think you can do this without modifying your trigger. You can use SUSER_NAME() function inside your trigger and if it matches with the login user bypass the execution.

to be specific.

The first line of trigger code will be if SUSER_NAME() = 'Manuel' return|||I can second that, you will have to implement some additional logic to make this possible.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de