简体   繁体   中英

Convert string in textbox to int

I have pass text from datagridview to textbox like this;

convictions.label2.Text = this.dataGridView3.CurrentRow.Cells[0].Value.ToString();

and then update the data like this;

void UPDATEConviction(string a, string b, string c, string d, string e, string f, string g, string h)
{
using (SqlConnection conn = getc())
{
SqlCommand cmd = new SqlCommand("update Conviction set Date_Convicted =@a, Court_File=@b, Police_File=@c, Station=@d,Offence=@e,Sentence=@f,Convict_Status=@g Where Serial_no = @h", conn);
cmd.Parameters.AddWithValue("@a", a);
cmd.Parameters.AddWithValue("@b", b);
cmd.Parameters.AddWithValue("@c", c);
cmd.Parameters.AddWithValue("@d", d);
cmd.Parameters.AddWithValue("@e", e);
cmd.Parameters.AddWithValue("@f", f);
cmd.Parameters.AddWithValue("@g", g);
cmd.Parameters.AddWithValue("@h", SqlDbType.Int);
conn.Open();
cmd.ExecuteNonQuery();
dataGridView3.DataSource = GetConvictoin();
}  
}

how do i convert h into interger so the data is updated

I have tried searching for a method but nothing seems to work

try this

cmd.Parameters.AddWithValue("@h", Convert.ToInt32(h));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM