A little noob says HY. I have a small problem with a homework project in Microsoft Visual Studio 2010. Also, i work in C#. I must do a site for selling products and i have an Access database. So, the problem is this: i wrote code but it seems something is wrong and i don't know what! When i try to Add a command by site i receive an error:
Data type mismatch in criteria expression.
Code is:
string date = DateTime.Now.ToShortDateString();
string string_baza_de_date = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\BogCs\Documents\Visual Studio 2010\WebSites\WebSite1\App_Data\magazin.mdb";
OleDbConnection ConexiuneSQL = new OleDbConnection(string_baza_de_date);
ConexiuneSQL.Open();
int numar_total_de_produse = CheckBoxList1.Items.Count; // se numara produsele
for (int i = 0; i < numar_total_de_produse; i++) // de la primul articol din CheckBoxList1 pana la ultimul
{
if (CheckBoxList1.Items[i].Selected == true) // daca am selectat un produs
{
// interogarea comenzii:
string interogare_adauga_comanda = "INSERT INTO comanda_finala (ID_comanda, ID_client, ID_produs, produs, tip_produs, data_comanda, pret) VALUES ("
+ TextBox1.Text + ",'" + TextBox2.Text + "',"
+ CheckBoxList1.Items[i].Value + ",'" + CheckBoxList1.Items[i].Text + "', 'Televizoare LED','"
+ data_curenta + "','" + GridView3.Rows[i].Cells[3].Text.ToString() + "');";
OleDbCommand comanda_inserare_comanda = new OleDbCommand(interogare_adauga_comanda, ConexiuneSQL);
comanda_inserare_comanda.ExecuteNonQuery();
}
}
ConexiuneSQL.Close();
GridView3.Visible = false;
Button1.Visible = false;
Button2.Visible = false;
CheckBoxList1.Visible = false;
Label1.Visible = false;
TextBox1.Visible = false;
Label2.Visible = true;
When i press "Add command" gives me that error and i don't know how to solve!