bdesh tiger

bdesh tiger

  • NA
  • 4
  • 0

reading data from table

Nov 14 2010 5:28 PM

Hi all,
I am using C# - VS2008, oracle 11g DB
I want to scan barcode and it should query the data from database and fill remaining text boxes. I can do it by datareader command but i want to use by dataset command. I have added few lines of codes under txtBarcode_Leave() as follows:
{ cboCategory.Text = ds1.Tables["barcode"].Columns["category"].ToString(); }

The above line codes return category field title (not category field data). But i want to read data from category field as per barcode...... My sample codes are below:
private void txtBarcode_Leave(object sender, EventArgs e)
DataSet
ds1 = new DataSet();
ds1 = rs.DataSet1(
"select category, price from barcode where barcode = '" + txtBarcode.Text +"'","barcode");
if (ds1!=null && ds1.Tables[0].Rows.Count !=0)
{ cboCategory.Text = ds1.Tables[
"barcode"].Columns["category"].ToString(); }
else { error shows....}
ds1.Dispose();}
 
public DataSet DataSet1(string lssql, string stablename)
{
connectionopen();Dataset ds = new DataSet();
da =
new OleDbDataAdapter(lssql, cnn);
da.Fill(ds, stablename);

return ds;

}
Can someone help me how to get data from table by using dataset command, would be appreciated.
Best regards,
BT

Answers (2)