Click here to Skip to main content
15,891,204 members
Home / Discussions / Database
   

Database

 
GeneralJoin Table in 2 different database files Pin
ting66827-Feb-05 22:55
ting66827-Feb-05 22:55 
GeneralRe: Join Table in 2 different database files Pin
Yulianto.27-Feb-05 23:09
Yulianto.27-Feb-05 23:09 
GeneralRe: Join Table in 2 different database files Pin
ting66827-Feb-05 23:45
ting66827-Feb-05 23:45 
GeneralRe: Join Table in 2 different database files Pin
Yulianto.28-Feb-05 18:03
Yulianto.28-Feb-05 18:03 
GeneralProgramming Microsoft Outlook... two problems Pin
devvvy27-Feb-05 16:04
devvvy27-Feb-05 16:04 
GeneralUpdate an item in MySQL with VS2003 Pin
kd834127-Feb-05 15:21
kd834127-Feb-05 15:21 
QuestionHow to display menu in a child form of SQL Server Enterprise Manager Pin
xshi00527-Feb-05 9:22
xshi00527-Feb-05 9:22 
GeneralSyntax error on IF ELSE statement Pin
rudemusik27-Feb-05 7:22
rudemusik27-Feb-05 7:22 
Hello All!

I'm working on a Store Procedure. This works fine...
SELECT MAX(TableID) AS returnvalue
FROM TblID
WHERE (Inuse = 0)
UPDATE T1
SET Inuse = 1
FROM TblID T1 INNER JOIN
(SELECT MAX(TableID) AS MaxT
FROM TblID
WHERE (Inuse = 0) AND (TableID <= 5)) T2 ON T1.TableID = T2.MaxT

But now I need to make it so if the VALUE of "InUse" is not 0, it will give an error message or something. I will use this SP in my VB.net program. Unless it is easier to catch the error on the client side within my program. But I thought this would be the better way to go. And if I do have a message built in the SQL code, how can I display that in my code for my program.
This is what I have now for the SP code....
IF (SELECT MAX(TableID) AS returnvalue
FROM TblID
WHERE Inuse = 0) BEGIN
UPDATE T1
SET Inuse = 1
FROM TblID T1 INNER JOIN
(SELECT MAX(TableID) AS MaxT
FROM TblID
WHERE (Inuse = 0) AND (TableID <= 5)) T2 ON T1.TableID = T2.MaxT END ELSE BEGIN PRINT ' Wrong'

And if your curious, this is my code to call the SP in vb.net....

conLog = New SqlConnection("Server=localhost;uid=**;pwd=**;database=footbet")
cmdLog = New SqlCommand("loginStore", conLog)
cmdLog.CommandType = CommandType.StoredProcedure
cmdLog.Parameters.IndexOf("@InUse")
conLog.Open()
cmdLog.ExecuteScalar()
myMainfrm.Show()
conLog.Close()

Thank you for your help!

Rudy
GeneralRandom data Pin
vuthaianh26-Feb-05 17:00
vuthaianh26-Feb-05 17:00 
GeneralRe: Random data Pin
NeverHeardOfMe27-Feb-05 11:32
NeverHeardOfMe27-Feb-05 11:32 
GeneralRe: Random data Pin
vuthaianh28-Feb-05 15:08
vuthaianh28-Feb-05 15:08 
GeneralRe: Random data Pin
NeverHeardOfMe2-Mar-05 22:45
NeverHeardOfMe2-Mar-05 22:45 
QuestionHow to serialize the database (SQL Server) Pin
oohungoo26-Feb-05 15:18
oohungoo26-Feb-05 15:18 
QuestionCan I create an Access type database from ADO/C# .NET? Pin
MitchellBaldwin26-Feb-05 6:07
MitchellBaldwin26-Feb-05 6:07 
AnswerRe: Can I create an Access type database from ADO/C# .NET? Pin
Mike Ellison26-Feb-05 8:09
Mike Ellison26-Feb-05 8:09 
AnswerRe: Can I create an Access type database from ADO/C# .NET? Pin
Mike Ellison26-Feb-05 8:13
Mike Ellison26-Feb-05 8:13 
GeneralRe: Can I create an Access type database from ADO/C# .NET? Pin
MitchellBaldwin26-Feb-05 10:53
MitchellBaldwin26-Feb-05 10:53 
GeneralPopulating textbox(s) from Column(s) Pin
WindSailor25-Feb-05 14:04
WindSailor25-Feb-05 14:04 
GeneralRe: Populating textbox(s) from Column(s) Pin
numbrel26-Feb-05 4:20
numbrel26-Feb-05 4:20 
GeneralRe: Populating textbox(s) from Column(s) Pin
WindSailor28-Feb-05 23:38
WindSailor28-Feb-05 23:38 
GeneralRe: Populating textbox(s) from Column(s) Pin
numbrel1-Mar-05 3:53
numbrel1-Mar-05 3:53 
GeneralDatabase paging Pin
grea faflj25-Feb-05 5:49
grea faflj25-Feb-05 5:49 
GeneralRe: Database paging Pin
Jon Sagara25-Feb-05 7:02
Jon Sagara25-Feb-05 7:02 
GeneralSQL2000 RS Clarification Pin
mysorian25-Feb-05 3:28
professionalmysorian25-Feb-05 3:28 
GeneralADO.NET dataset w/o database Pin
scion780925-Feb-05 3:17
scion780925-Feb-05 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.