Question: Hello. I'm having trouble with my application. The code only pick ups and shows the same invoice even if the invoice id isn't there. As
Hello. I'm having trouble with my application. The code only pick ups and shows the same invoice even if the invoice id isn't there. As long as I enter an integer, it shows the same result. Any help will be much appreciated.
My Code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; namespace InvoiceLineItems { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void fillByInvoiceIDToolStripButton_Click(object sender, EventArgs e) { try { int InvoiceID = Convert.ToInt32( invoiceIDToolStripTextBox.Text); this.invoiceLineItemsTableAdapter.FillByInvoiceID( this.MMABooksDataSet1.InvoiceLineItems, InvoiceID); this.invoicesTableAdapter.FillByInvoiceID( this.MMABooksDataSet1.Invoices, InvoiceID); if (invoiceLineItemsBindingSource.Count > 0) this.invoicesTableAdapter.FillByInvoiceID( this.MMABooksDataSet1.Invoices, InvoiceID); else MessageBox.Show("No invoice found with this ID. " + "Please try again.", "Invoice Not Found"); } catch (FormatException) { MessageBox.Show("Invoice ID must be an integer.", "Entry Error"); } catch (SqlException ex) { MessageBox.Show("Database error # " + ex.Number + ": " + ex.Message, ex.GetType().ToString()); } } } }
Edit: What kind of information do you need? If you need more information, please be specific as "need more information" is not clear, nor helpful.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
