Actually I'm trying to do small form that has a textbox for BARCODE which when I scan an item it will add on my listview but I recieved this error that I don't know what went wrong in my code
"System.NullReferenceException: Object reference not set to an instance of an object."
private void text1_down(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
try
{
OracleDataAdapter xx = new OracleDataAdapter("SELECT * FROM POS WHERE barcode = " + this.textBox1.Text, conn);
ww = cmnd.ExecuteReader();
DataSet DS = new DataSet();
xx.Fill(DS, "pos");
DataTable dtable = DS.Tables["pos"];
// Display items in the ListView control
for (int i = 0; i < dtable.Rows.Count; i++)
{
DataRow drow = dtable.Rows[i];
// Only row that have not been deleted
if (drow.RowState != DataRowState.Deleted)
{
// Define the list items
ListViewItem lvi = new ListViewItem(drow["product_name"].ToString());
lvi.SubItems.Add(drow["price"].ToString());
// Add the list items to the ListView
listView2.Items.Add(lvi);
}
}
}
catch (Exception error)
{
MessageBox.Show(error.ToString());
}
}
}
Could anyone help me to fix this code
This post has been edited by eclipsed4utoo: 20 January 2012 - 06:31 AM
Reason for edit:: Please learn how to use the code tags

New Topic/Question
Reply



MultiQuote





|