string conString = "Server=192.168.1.100;Database=product;Uid=newuser;Pwd=password";
MySqlConnection conn = new MySqlConnection(conString);
DataTable dt = new DataTable();
DataRow row = dt.NewRow();
conn.Open();
//cmd = conn.CreateCommand();
//cmd.CommandText = "Select * From tblindividualproduct";
if (e.KeyCode == Keys.Enter)
{
if (txtBarcode.Text == "")
{
MessageBox.Show("Please Fill the correct ProductID");
}
else
{
string sql = "Select * From tblindividualproduct where ProductID = @ProductIdText";
using (var adapt = new MySqlDataAdapter(sql, conn))
using (var cmd = new MySqlCommandBuilder(adapt)) //Not sure what you need this for unless you are going to update the database later.
{
adapt.SelectCommand.Parameters.AddWithValue("@ProductIdText", txtBarcode.Text);
BindingSource bs = new BindingSource();
adapt.Fill(dt);
bs.DataSource = dt;
dgItems.ReadOnly = true;
dgItems.DataSource = bs;
}
}
}
How do I make the results to add, not just replace the last result. This is the whole code as requested. I just dont know if it needs manually adding of rows or there is an easy way to make it. Thank in advance