Ver Mensaje Individual
  #6 (permalink)  
Antiguo 16/01/2008, 19:07
Avatar de mdavila
mdavila
 
Fecha de Ingreso: julio-2007
Ubicación: Montevideo (Uruguay)
Mensajes: 919
Antigüedad: 16 años, 9 meses
Puntos: 13
Re: Ayuda para un principiante

Perdon es asi:

SqlConnection SqlConn = new SqlConnection("Data Source=xxx;Initial Catalog=xx;Persist Security Info=True;User ID=xxx;Password=xxx");

SqlDataAdapter objAdapter = new SqlDataAdapter("select razon_social from proveedor where rut = '" + tbrut.Text + "' ", SqlConn);
DataSet ds = new DataSet();

objAdapter.Fill(ds, "proveedor");
string Temp = new string();

foreach (DataRow dr in ds.Tables["proveedor"].Columns){
Temp = dr[0].ToString();
}
vtbrut.Text = Temp;


Pero hay formas mejores y mas eficientes de hacerlo sin tanta cosa ok, pero si lo entendes mejor asi......

Esta es un poquito mejor;

SqlConnection SqlConn = new SqlConnection("Data Source=xxx;Initial Catalog=xx;Persist Security Info=True;User ID=xxx;Password=xxx");

SqlCommand objAdapter = new SqlCommand("select razon_social from proveedor where rut = '" + tbrut.Text + "' ", SqlConn);
SqlDataReader dr;

dr = objAdapter.ExecuteReader();


while (dr.Read())
{
tbrut.Text = dr.GetValue(0).ToString();
}