473,796 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Identifying Connection

Hi All
The problem:!!
I want to create a temp table which is common between different users
so that each user could select his rows and print them without
printing others selection.
All clients use the same connection string.
Is there a way to identify users?
I think it's possible to delete rows of a user when he logs out the
program.
Do I think right?

thanks very much
Hafez
Jul 20 '05 #1
1 1717
Hafez (ha**********@m sn.com) writes:
The problem:!!
I want to create a temp table which is common between different users
so that each user could select his rows and print them without
printing others selection.
All clients use the same connection string.
Is there a way to identify users?
I think it's possible to delete rows of a user when he logs out the
program.
Do I think right?


If all you want is a table that goes away with the connection, then
create a temp table like this:

CREATE TABLE #temp (col1 int NOT NULL, ...)

That table is private to the connection, and it goes away when you
disconnect.

There are however situations where this is not feasible. A common technique
in that case is to use @@spid as the key in the table:

CREATE TABLE transient (spid int NOT NULL,
col1 int NOT NULL,
...)
go
DELETE transient WHERE spid = @@spid
INSERT transient(spid, col1, col2, ...)
SELECT @@spid, ...
go
SELECT col1, ...
FROM transient
WHERE spid = @@spid
AND ...

Here there is no automatic cleanup at exit, which is why you must delete
before you can insert anything, so that data that is around from the
previous connection is around.

However, neither this solution is always good. In modern clients you often
work disconnected, and reconnect only when you have something to say
SQL Server. In that case, you may get a different connection. Also, a
popular library like ADO can sometimes open a second connection behind
your back, although you only have one connection object.

To address this you can have some method to get a unique key that is
a negative number (so that you can use @@spid when that is safe.) We
have som 20 tables of this kind in our system, and we get they by
taking checksum(newid( )) and the register the key in a special table
which is then cleaned up at night. A simpler approach may be to simply
use a GUID column instead of integer.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4695
by: Mark | last post by:
I have an application that uses PHP to access a MySQL table and extract rows which match the user's search entry. Data from the matching rows are loaded into an HTML selection list, and the user can scan the list and highlight a selected item. My question: In PHP, what is the syntax for identifying which row is highlighted? My goal is to pass the unique row ID of the selected item to a subsequent form where all the fields will be...
1
6163
by: David | last post by:
I know that identifying the user IP address with HTTP_SERVER_VARS; is reliant on the browser agent but I have stumpled upon the following code which I have tried to understand but failed! // // Obtain and encode users IP //
1
5184
by: hokiegal99 | last post by:
This is not really a Python-centric question, however, I am using Python to solve this problem (as of now) so I thought it appropiate to pose the question here. I have some functions that search for files that contain certian strings and if the files found to have these string do not already have a filename extension (such as '.doc' or '.xls') the function will append that to the files and rename them. So, if a file named 'report' was...
0
1546
by: Joshua Beall | last post by:
Hi All, I've been taking a look at DB Designer 4, and looking through the documentation (http://www.fabforce.net/dbdesigner4/doc/index.html) I am a little unclear on some of their nomenclature: '1:1' - Ok, one to one. Got it. '1:1 generalization' - Don't know this. Obviously different somehow from one to one, but how? '1:n' - One to many, I assume.
7
2478
by: bill.brennum | last post by:
Hi, Have a number of Access Databases that I inherited and want to zip a few of them. My concern is that other active Microsoft Applications may be linking to the database or its tables. Is there a method of searching that will allow me to identify those MS Access files that are linked to. I am not really concerned with itemizing the which files link to which, but just that a link exists. Thanks in advance for any help.
0
388
by: Jack Kerkhof | last post by:
We have a database that sets a column called MOD_BY = CURRENT_USER to almost all tables on INSERT and UPDATE. But now that the application is n-tier, and uses connection pools, the current_user no longer reflects the 'application user'. Is there any way to temporarily alter 'current_user' with an alias for the duration of a transaction? IE ....<set current_user = 'application user alias'>...
1
1496
by: Jeff | last post by:
Okay, I know there is likely no straght-forward way to get a definitive answer to the question, "why is my page loading so slowly tonight?"; but I'm thinking that there *are* some things we can measure to get *some* general idea of where the bottleneck is. I can sit here and theorize about why it's periodically slow, but I'd like to be able to know what's causing the periodical performance degradation. My situation is that I have an...
2
6879
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless there is a problem with the connection. I need to know which client has sent the incoming data as each client has its own buffer on my "server" app. I am using the standard asynch socket code from MSDN to listen for connections and they...
10
4514
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under consideration here is that it is supplied to the AsyncOperationManager.CreateOperation(userSuppliedState) method... with userSuppliedState being, more or less, a taskId. In this case, the userSuppliedState {really taskId} is of the object type,...
0
9680
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.