You need to be calling the .Value
property on your dataGridView1
, not the .Text
property.
Something like this:
private void button1_Click(object sender, EventArgs e)
{
// Adding Values to Data Base
string mySQL = "INSERT INTO Employee_login VALUES ("
+ Convert.ToInt32(dataGridView1.Rows[RowCount - 1].Cells[0].Value) + ", '"
+ dataGridView1.Rows[RowCount - 1].Cells[1].Value + "','";
}
You didn't mention in your post however, if you actually need to call the .Trim()
method; which will not work in this case using .Value
.