Poppa Wallace

Poppa Wallace

  • NA
  • 189
  • 24.2k

Datagridview to MYSQL, think int is my problem

Nov 28 2016 5:55 AM
Can I get a little help with my insert statement. This is going to MYSQL. PageNumber and SlotPosition are both (int) which is why I think its failing.
 
 
But if I do 
 
+ Convert.ToInt32(dataGridView2.Rows[i].Cells["PageNumber"].Value) + "','"
 
the other fields become Null. 
 
String cmdText = "INSERT INTO merchantitem (MerchantItem_ID, ItemListID, ItemTemplateID, PageNumber, SlotPosition) VALUES ('"
+ dataGridView2.Rows[i].Cells["MerchantItem_ID"].Value + "','"
+ dataGridView2.Rows[i].Cells["ItemListID"].Value + "','"
+ dataGridView2.Rows[i].Cells["ItemTemplateID"].Value + "','"
+ dataGridView2.Rows[i].Cells["PageNumber"].Value + "','"
+ dataGridView2.Rows[i].Cells["SlotPosition"].Value + "')";
MySqlCommand cmd = new MySqlCommand(cmdText, constr);
cmd.ExecuteNonQuery();

Answers (1)