Estoy empezando con la base de datos y me trae de cabeza. A parte de preguntaros por un buen manual, os pongo una sencilla cuestion que me trae de cabeza.
Como introduzco el valor de un campo del dataset a un textbox?
Tengo esto, para servir de guía:
SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=basededatos;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.CommandText="SELECT * FROM vehiculos WHERE Matricula=@Matricula";
cmd.Parameters.Add("@Matricula", SqlDbType.Char );
cmd.Parameters["@Matricula"].Value = this.txtbMatricula.Text;
cmd.Connection=cn;
//Creamos el dataAdapter
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand=cmd;
//Creamos el dataset ds
DataSet ds = new DataSet();
// Rellenamos el DataSet con los datos obtenidos a partir de la consulta
try
{
da.Fill(ds,"Vehic");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error al trabajar con la base",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//Introducir un valor de la tabla a un textbox
Gracias por leer hasta aqui
