I am try to inset data into another table from the first table. I pass 2 things from the Website to the [WebMethod].
[WebMethod]
public string purchaseInfo(int itemID, string logedInEmail)
When i run this an exception is thrown saying
"Data type mismatch in criteria expression".
try
{
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT ItemID, itemName, description, price FROM ItemInfo WHERE (ItemID = '" + itemID + "')"; //ItemID is a AutoNumber field.
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read()) // Reading the data selected
{
int currentItemID = (int)reader["ItemID"];
string currentItemName = (string)reader["itemName"];
string currentdescription = (string)reader["description"];
string currentPrice = (string)reader["price"];
cmd.CommandText = @"INSERT INTO PurchaseInfo (itemID, buyerIDEmail, itemName, description, price)
VALUES ('" + currentItemID + "', '" + logedInEmail + "', '" + currentItemName + "', '" + currentdescription + "', '" + currentPrice + "')";
cmd.ExecuteNonQuery();
}
conn.Close();
return "Successful";
}
catch (Exception ex)
{
return ex.Message;
}
I have checked if all the data fields are the correct type in the database, and as far as I can tell they are. currentItemID is inserted into Number field. and the rest is all inserted into a Short Text field.
Don't know if it matter but there is also an Auto number field in PurchaseInfo.