private void button1_Click(object sender, EventArgs e)
{
Staff s = new Staff();
staffAG j = new staffAG();
j.id = comboBox2.Text; error in this row "cannot implicitly convert type string to int"
j.name = textBox2.Text;
j.age = textBox3.Text;
j.phone = textBox4.Text;
j.address = textBox5.Text;
j.post = comboBox1.Text;
s.updatestaff(j);
MessageBox.Show("Record updated");
}
coding of my class staff is
public void updatestaff(staffAG j)
{
int z = 0;
cn.Open();
cmd = new SqlCommand("update staff set name = @name,age = @age,phoneno = @phoneno,address = @address,post = @post where id = @id", cn);
cmd.Parameters.AddWithValue("@id",Convert. ToString (j.id));
cmd.Parameters.AddWithValue("@name",j.name);
cmd.Parameters.AddWithValue("@age",j.age);
cmd.Parameters.AddWithValue("@phoneno",j.phone);
cmd.Parameters.AddWithValue("@address",j.address);
cmd.Parameters.AddWithValue("@post",j.post);
cmd.ExecuteNonQuery();
cn.Close();
{
MessageBox.Show("Added");
}
}
coding of my class staffAG is
class staffAG
{
int _id;
string _name;
string _age;
string _phone;
string _address;
string _post;
string _gender;
public string name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public int id
{
get
{
return _id;
}
set
{
_id = value;
}
}
public string age
{
get
{
return _age;
}
set
{
_age = value;
}
}
public string phone
{
get
{
return _phone;
}
set
{
_phone = value;
}
}
public string address
{
get
{
return _address;
}
set
{
_address = value;
}
}
public string post
{
get
{
return _post;
}
set
{
_post = value;
}
}
public string gender
{
get
{
return _gender;
}
set
{
_gender = value;
}
}
why error is shown in my button coding
j.id=combobox1.text; "cannot implicitly convert type string to int"
please help me if an other problem with my coding for update staff also tell me...sorry for my English....