uint GetProductId(string product, uint memberId)
{
if (product.Length > 128)
product = product.Substring(0, 128);
if (!mProductIDs.ContainsKey(product))
{
string sql = "INSERT INTO products (product_name, member) VALUES ('" + product + "', '" + memberId + "')";
try
{
MySqlCommand cmd = new MySqlCommand(sql, mSql);
cmd.ExecuteNonQuery();
// Now querry the database for the index
sql = "SELECT * FROM products WHERE product_name='" + product + "'";
cmd = new MySqlCommand(sql, mSql);
MySqlDataReader r = cmd.ExecuteReader();
r.Read();
uint ID = (uint)r[0];
r.Close();
mProductIDs[product] = ID;
}
catch (Exception ex)
{
Email.SendErrorEmail(sql + "\n\n" + ex.ToString());
}
}
return mProductIDs[product];
}