Facebook is a class where I store user information, but I do not know how to use ExecuteReader
to get the information.
Can anyone help me with this? (I'm new to C # language)
public Usuario buscarUsuario(int id){
Usuario usuario = new Usuario ();
string sql = "SELECT * FROM usuario WHERE id = " + id;
try{
Csql = new ConectSQL();
MySqlCommand cmd;
cmd = new MySqlCommand();
cmd.Connection = Csql.OpenBanco();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
MySqlDataReader rdr;
rdr = cmd.ExecuteReader();
if(rdr.HasRows)
while(rdr.Read()){
usuario.Id = rdr.GetInt32(0);
usuario.Nick = rdr.GetString(1);
usuario.Cadastro = rdr.GetString(2);
usuario.Tipo = rdr.GetInt32(3);
usuario.Facebook = rdr.GetString(4); //eu não set q get usar.
}
Csql.CloseBanco();
return usuario;
}
This is the error that is appearing.
Assets / DAO / UserID.cs (52,49): error CS0029: Can not implicitly convert type 'string' to 'FaceBook'