Yes it is because you didn`t introduce your
connection
to
command
object. which means you need to do like this:
string queryString = "SELECT OrderID, CustomerID FROM Orders";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetInt32(0) + ", " + reader.GetString(1));
}
reader.Close();
}
So, if I want to write your code I prefer the below one:
private void flowButton3_Click(object sender, EventArgs e)
{
string pq = "sold";
try{
OleDbConnection con = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Login App\SmartShop.accdb");
String update_sql = "UPDATE Items SET[status] = '" + pq + "', WHERE [ItemID] IN (" + String.Join(",", Array.ConvertAll(strarray, z => "'" + z + "'")) + ")";
OleDbCommand update = new OleDbCommand(update_sql,con);
con.Open();
update.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
One more update, try to don`t use blank char in Database path and try to use several objects and variables for storage input parameters because they can help you in truck, maintenance and code readability.
For more information read the blow link:
https://msdn.microsoft.com/en-us/library/dw70f090(v=vs.110).aspx[
^]
R,
Aydin