Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 If Else Statement

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2007-10-31 : 09:24:46
I'm trying to catch an error with this code:

If TopicTxt.Text = "" Then
Lbloutcome.Text = "Your topic was submitted into the database."
Else
Lbloutcome1.Text = "Duplicate entry topic already in database, topic was not submitted"
End If

When I enter a duplicate entry I get the Lbloutcome1.text message but if I enter an entry that's not a duplicate it's submitted but I don't get "Your topic was submitted into database". What am I doing wrong

nr
SQLTeam MVY

12543 Posts

Posted - 2007-10-31 : 09:28:48
I'm guessing it's because TopicTxt.Text isn't = ""
Also guess this isn't sql server code.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2007-10-31 : 09:30:59
Your correct I'm in the wrong forum will go to another. Thanks.
Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-01 : 06:45:15
this is not a sql code as much as i know
most probably you are wrking in .net technology
so first use the correct format of sql server if u r wrking in sql

as
if condition
begin
----
---
end
else
begin
----
----
end



and in ur case your logic is problematic its only checking whether the text box is empty or not its not matching the value present already

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA
Go to Top of Page
   

- Advertisement -