I have this method using webservice to connect my desktop app to a oracle database:
public List<Persona> ListaPersona()
{
List<Persona> personas = new List<Persona>();
Persona persona;
Conexion con = new Conexion();
OracleCommand cmd = con.OracleConexion().CreateCommand();
cmd.CommandText = "select * from persona";
DataSet ds = new DataSet();
OracleDataAdapter adapter = new OracleDataAdapter(cmd);
adapter.Fill(ds);
foreach (DataRow fila in ds.Tables[0].Rows)
{
persona = new Persona();
persona.IdPersona = Int32.Parse(fila["IDPERSONA"].ToString());
persona.Rut = Int32.Parse(fila["RUT"].ToString());
persona.DigiVeri = fila["DIGIVERI"].ToString();
persona.Nombre = fila["NOMBRES"].ToString();
persona.ApPaterno = fila["APPATERNO"].ToString();
persona.ApMaterno = fila["APMATERNO"].ToString();
persona.Edad = Int32.Parse(fila["EDAD"].ToString());
persona.FechaNacimiento = fila["FECHA_NACIMIENTO"].ToString();
persona.Genero = fila["GENERO"].ToString();
persona.Correo = fila["CORREO"].ToString();
persona.Telefono = Int32.Parse(fila["TELEFONO"].ToString());
persona.Direccion = fila["DIRECCION"].ToString();
persona.Comuna = Int32.Parse(fila["COMUNA"].ToString());
persona.Contrasena = fila["CONTRASENA"].ToString();
persona.Empresa = Int32.Parse(fila["EMPRESA"].ToString());
persona.Cargo = Int32.Parse(fila["CARGO"].ToString());
persona.Activo = Int32.Parse(fila["ACTIVO"].ToString());
persona.Expositor = Int32.Parse(fila["EXPOSITOR"].ToString());
persona.Personal = Int32.Parse(fila["PERSONAL"].ToString());
persona.FechaIngreso = fila["FECHA_INGRESO"].ToString();
personas.Add(persona);
}
return personas;
}
It returns the list of all the users registered on the system, and i show them on a gridview. It display the data perfect, but in some random order i don't know why, so i wan't to reorder the colums of the gridview.
This is the windowsform load code:
public testLista()
{
InitializeComponent();
WebService.ServicioClient s = new WebService.ServicioClient();
dataGridView1.DataSource = s.ListaPersona().ToList();
}
You can map it manually. On your DataGridView, you will see a triangle to the top right bottom. There you can map it manually according to the order you like. (Sorry, I coouldn't comment since I need 50 reputation, I only have 11)
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.