4
Reply

Order by (doesnt works)

Israel

Israel

Apr 23 2016 10:19 AM
318
Hi!
How can I filter by order? I do try this but its doesnt works properly:
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\lunaoffice\lunaoffice\\app_data\office.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from stock order by N_O where code ='" + txtCode.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
txtNumber.Text = read["number"].ToString();
txtProduct.Text = read["product"].ToString();
}
}
else
{
MessageBox.Show("This code " + txtCode.Text + " doenst exist");
}
read.Close();
sqlCon.Close();

Answers (4)