Hi Alex,
Thanks again for your idea! I put it to work, and I think I almost got it,
just a little bump. Here is the store proc that I have.
CREATE PROCEDURE [dbo].[max tableid] AS
SELECT MAX(TableID) AS Expr1
FROM TableID
WHERE (Inuse =0)
GO
My table"tableID", has a tableid col, and a Inuse col. my tableID is set
from 1- 5. my inuse is a bit, 1 or 0. 1 the table is in use, 0 the table is
free.
Here is a snippet of my code.
cmdLog = New SqlCommand("Max TableID", conLog)
cmdLog.CommandType = CommandType.StoredProcedure
TableIDReturn = cmdLog.Parameters.Add("ReturnValue", SqlDbType.Int)
TableIDReturn.Direction = ParameterDirection.ReturnValue
conLog.Open()
cmdLog.ExecuteNonQuery()
intTableID = cmdLog.Parameters("ReturnValue").Value
If intTableID <= 5 Then
myMainfrm.Show()
Else : intTableID = 0
MessageBox.Show("Sorry")
conLog.Close()
End If
My question is how can I have my "if"command select only from 1 to 5, and if
nothing shows up in the col, if all the tables were in use, that value = 0.
Thanks again for your help!
"Alex" wrote:
> Hi Rudy,
> I am not sure about this, but since you are using a windows app you
> might not be connected to your SQL Server over the whole application
> life cycle. I would simply add a new column to your users table called
> *locked* or whatever. As soon as a client connects to your DB you get
> the highest ID which is not locked.
> Like
> Select Max(userID) from users where locked = false
> You apply this ID to the client.
>
> Now, you have to make sure that when the client closed the app he frees
> the ID for other users.
>
> You can catch the close event of the main form and set the locked state
> of the user ID back to false.
>
> Maybe you have to add additional mechanisms to ensure that users are
> unlocked when the app crashes...
>
> Kind regards
> Alex
>
>
>
> http://www.flashshop.info
>
> Rudy wrote:
> > Hello all!
> >
> > I'm working on a windows app, using SQL for my databse. I have a table
> > named "user id". There are 50 user numbers, ranging from 1-50. The numbers
> > are actually the login. no password. I would like to have a user sit down at
> > a computer, hit a button and go. I need the computer to be logged in from
> > the list of 50 number. If number 34 is taken for example, it continues to
> > look for a free number, until it finds one, then logs in.
> >
> > Any ideas on what is the best way to approach this?
> >
> > Thanks!!
> >
> > Rudy
>