vb.net - error filling the data adapter when I select an item from a dropdown


I'm doing 3 dropdown, one that is "department", the other one is "province" and the last one is "district". When my page loads, it is already pulling data from the database in the "department" dropdown, but when I click on one of those data I drop the program. What I try to do is just that the user selects an item from a dropdown and then the other dropdown is filled depending on which item he chose.



Public Class Registrar
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not Page.IsPostBack Then
    End If

End Sub

Protected Sub btnRegistrar_Click(sender As Object, e As EventArgs) Handles btnRegistrar.Click

    Dim clRegistrar As New SIMULADOR_LOG.clsExamenLOG
    Dim User As New SIMULADOR_ENT.clsUsuarioSim
    With User
        .dni_user = txtDNI.Text
        .ape_pat_user = txtApellidoPaterno.Text
        .ape_mat_user = txtApellidoMaterno.Text
        .nombre_user = txtNombres.Text
        .direccion_user = txtDireccion.Text
        .celular_user = txtCelular.Text
        .correo_user = txtCorreo.Text
        .ubigeo = txtUbigeo.Text
        .fech_nacimiento = txtFechaNacimiento.Text
    End With

    Dim mensajeLog As String = clRegistrar.RegistrarUsuario(User)

    Dim Mensaje As String = "<script type=""text/javascript"">" &
                                "Message('El sistema dice: " & mensajeLog & "')</script>"

    ClientScript.RegisterStartupScript(Me.GetType, "msg", Mensaje)

End Sub

Protected Sub cmbDepartamento_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbDepartamento.SelectedIndexChanged

    Dim clRegistrar As New clsExamenLOG

    Dim dpto As String = cmbDepartamento.SelectedValue
    cmbProvincia.DataSource = clRegistrar.Consultar("SELECT DISTINCT prov FROM up100.UBIGEO WHERE DPTO =" & dpto)
    cmbProvincia.DataTextField = "prov"
    cmbProvincia.DataValueField = "prov"
    cmbProvincia.Items.Insert(0, New ListItem("[Seleccionar]", "0"))

End Sub

Protected Sub cmbProvincia_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbProvincia.SelectedIndexChanged

    Dim clRegistrar As New clsExamenLOG

    Dim prov As String = cmbProvincia.SelectedValue

    cmbDistrito.DataSource = clRegistrar.Consultar("SELECT DISTINCT disc FROM up100.UBIGEO WHERE PROV =" + prov)
    cmbDistrito.DataTextField = "disc"
    cmbDistrito.DataValueField = "disc"
    cmbDistrito.Items.Insert(0, New ListItem("[Seleccionar]", "0"))

End Sub

Protected Sub cmbDistrito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbDistrito.SelectedIndexChanged

End Sub

Sub iniciarLlenadoDropDown()

    Dim clRegistrar As New clsExamenLOG

    cmbDepartamento.DataSource = clRegistrar.Consultar("SELECT DISTINCT dpto FROM up100.UBIGEO")
    cmbDepartamento.DataTextField = "dpto"
    cmbDepartamento.DataValueField = "dpto"
    cmbDepartamento.Items.Insert(0, New ListItem("[Seleccionar]", "0"))
    cmbProvincia.Items.Insert(0, New ListItem("[Seleccionar]", "0"))
    cmbDistrito.Items.Insert(0, New ListItem("[Seleccionar]", "0"))

End Sub

End Class


Public Class clsExamenLOG

    Public Function Consultar(str As String) As DataSet
        Dim clConsulta As New clsExamen
        Dim resultado As DataSet = clConsulta.Consultar(str)
        Return resultado
    End Function
End Class


Imports Oracle.DataAccess.Client
Public Class clsExamen

Function Consultar(strSQL As String) As DataSet

        Dim Conex As New clsConexion
        Dim Cnx = Conex.Conexion

        Dim cmdConsultar As New OracleCommand(strSQL, Cnx)
        cmdConsultar.CommandType = CommandType.Text

        Dim oda As New OracleDataAdapter(cmdConsultar)

        Dim ds As New DataSet


        Return ds

    End Function

End Class

Error I get:

    [OracleException (0x80004005): ORA-00904: "PASCO": invalid identifier]
   Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) +1526
   Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck) +50
   Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) +3956
   Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +298
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +88
   SIMULADOR_DAO.clsExamen.Consultar(String strSQL) in C:\Users\gpoma.SANBORJA\Downloads\waSimExamen\SIMULADOR_DAO\clsExamen.vb:62
   SIMULADOR_LOG.clsExamenLOG.Consultar(String str) in C:\Users\gpoma.SANBORJA\Downloads\waSimExamen\SIMULADOR_LOG\clsExamenLOG.vb:6
   waSimExamen.Registrar.cmbDepartamento_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\gpoma.SANBORJA\Downloads\waSimExamen\waSimExamen\Registrar.aspx.vb:55
   System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +116
   System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent() +138
   System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +15
   System.Web.UI.Page.RaiseChangedEvents() +132
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1559

Error on line 62:

    Línea 60: 
Línea 61:         Dim ds As New DataSet
Línea 62:         oda.Fill(ds) 'Aquí sale el error
Línea 63: 
Línea 64:         cmdConsultar.Dispose()
asked by Gian Franco Alexis Poma Vidal 10.12.2018 в 20:24

0 answers