SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 ASP.NET
 If, Then, Else Statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

OfMartin
Starting Member

11 Posts

Posted - 04/16/2005 :  11:37:04  Show Profile  Reply with Quote
Dim strBarcode 'Barcode entered by user

If strBarcode = (this is what i need) Then
(this also)
Else 'Barcode is invalid
Beep() 'Warn user
lblHelp.Text = "Please enter a valid barcode"
End If

Hi everyone ,

This is my code to validate barcode entered by the user to see if it matches barcode existing from my database. I need a value or name on the other side of my If statement to represent "barcode that exists in my database". After my Then statment, I need my clause to tell my form to allow the barcode. I just don't know the code for this, so i'd figure I'd ask someone more competent and proficient at this.

Thanks in advance,
OfMartin890@yahoo.com

jhermiz
Flowing Fount of Yak Knowledge

USA
3564 Posts

Posted - 04/18/2005 :  13:19:59  Show Profile  Visit jhermiz's Homepage  Reply with Quote
You'll need to pick up a book on SQL. Your = (this is what I need)... I assume is just some sort of status which tells you whether a bar code exists or not. You really can do a check and an insert in one transaction. That is:

1) Check if the bar code exists...
2) If it doesnt add it else dont add it

Here is a sample sproc:


CREATE PROCEDURE insert_barcode    @barcode varchar(50),
AS
BEGIN
SET NOCOUNT ON

IF EXISTS(SELECT *
	     FROM MyBarCodes
	     WHERE barcode=@barcode
	    ) return -1  --i'm returning -1 back to the client application..already exists
ELSE
--if im here then the barcode does not exist and should be inserted...
INSERT INTO MyBarCodes (barcode) Values (@barcode)
RETURN SCOPE_IDENTITY()  --you could return the identity if you need it
Set NOCOUNT OFF
End
GO



Keeping the web experience alive -- http://www.web-impulse.com
Imperfection living for perfection --
http://jhermiz.blogspot.com/

Edited by - jhermiz on 04/18/2005 13:20:35
Go to Top of Page

qrcodenet
Starting Member

4 Posts

Posted - 01/17/2013 :  22:10:04  Show Profile  Reply with Quote
What kind of barcode you generated? You may input some data that is not included in the barcode standard. You may read tutorial again. I got one tutorial, you may have a look:http://www.tarcode.com/barcode-aspnet/generate-guide.html



bar code generation DLL
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000