I have a problem when entering data in a DropDownList, because I have the code, but at the time of logging in as a user does not show me information in the DropDownList and I do not know why, because Reviewed my query and it's fine. I leave the code waiting to help me.
if (!IsPostBack)
{
Int32 iCodigo;
if (Request.QueryString["id"] == null) //valido el usuario ingresado
{
using (OdbcConnection cn = new OdbcConnection(Conexión))
{
using (OdbcCommand cm = new OdbcCommand("SELECT SlpCode FROM Vendedores Where SlpName = '"+Request.QueryString["id"]+"'", cn)) //selecciono el ID del usuario que ingreso, pues necesito validarlo en la consulta siguiente
{
iCodigo = Convert.ToInt32(cm.ExecuteReader()); //asigno una variable de tipo Int al query para llamarla después.
}
}
OdbcConnection cnx = new OdbcConnection("Dsn=Conexion server;uid=sa;pwd=alimentaria");
OdbcCommand cmd = new OdbcCommand("SELECT A.CardCode, A.CardName, B.SlpName FROM Clientes A INNER JOIN Vendedores B ON A.SlpCode = B.SlpCode Where A.SlpCode = " + iCodigo+ " AND LicTradNum ='XAXX010101000'", cnx);
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
this.VENTA.DataSource = ds;
this.VENTA.DataValueField = "CardName";
this.VENTA.DataBind();
}
}