Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/05/2004, 14:52
Avatar de RsOfT
RsOfT
 
Fecha de Ingreso: marzo-2002
Ubicación: InterNET
Mensajes: 1.121
Antigüedad: 22 años, 11 meses
Puntos: 7
Pregunta Llenar un DataGrid con DataAdapter y DatSet por Código en ASP.NET

Estoy tratando de llenar un DataGrid de la siguiente forma:

Código:
strSQL = "Select cdCodigo, cdDescripcion from centroDistribucion"
Dim SQL_Command As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL)
Dim daCentroDist As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQL_Command)
Dim dsCentroDist As DataSet = New DataSet("dsCentroDist")

cnn.Open()
    daCentroDist.SelectCommand.CommandText = strSQL
    daCentroDist.Fill(dsCentroDist)
    
    cobCentroDist.DataSource = dsCentroDist
    cobCentroDist.DataTextField = "cdDescripcion"
    cobCentroDist.DataValueField = "cdCodigo"
    cobCentroDist.DataBind()
cnn.Close()
La variable cnn es un objeto de tipo SqlConnection agregado en forma de diseño.

Me tira el siguiente error:
===========================
Fill: SelectCommand.Connection property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Fill: SelectCommand.Connection property has not been initialized.

Source Error:

Line 45: daCentroDist.Fill(dsCentroDist)
===========================

Qué estoy haciendo mal?
__________________
.::RsOfT::.
--El que se aferra a lo conocido, nunca conocerá lo desconocido--
--Es intentando lo imposible como se realiza lo posible--
--Es de pésimo gusto contentarse con algo mediocre cuando lo excelente está a nuestro alcance--