tdignan87
Well-known member
- Joined
- Jul 8, 2019
- Messages
- 95
- Programming Experience
- Beginner
Hi i need some help please.
I have a textbox that the user scans into with a scanner and if the barcode exists i want another form to appear to allow them to continue, and if the barcode doesn't exist in the DB another form which will tell them.
I keep getting this flag though. Can anyone help please?
I have put messageboxes for now instead of the other forms.
Thanks
I have a textbox that the user scans into with a scanner and if the barcode exists i want another form to appear to allow them to continue, and if the barcode doesn't exist in the DB another form which will tell them.
I keep getting this flag though. Can anyone help please?
C#:
private void BarcodeTxtBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
FbConnectionStringBuilder rfs = new FbConnectionStringBuilder();
rfs.DataSource =
"localhost";
rfs.Port = ;
rfs.Database = @"";
rfs.UserID = "sysdba";
rfs.Password = "";
rfs.ServerType = FbServerType.Default;
FbConnection db = new FbConnection(rfs.ToString());
FbDataReader myReader = null;
string barcodeQuery = "SELECT COMMODITIES.CODE,COMMODITIES.NAME FROM COMMODITIES WHERE BARCODE = " + BarcodeTxtBox.Text + " ";
FbCommand myCommand = new FbCommand(barcodeQuery, db);
db.Open();
myReader = myCommand.ExecuteReader();
myReader.Read();
int count = Convert.ToInt32(myCommand.ExecuteScalar());
if (count > 0)
{
MessageBox.Show("Existed!");
}
else
{
MessageBox.Show("No record");
}
}
}
I have put messageboxes for now instead of the other forms.
Thanks