• Jueves 25 de Abril de 2024, 13:12

Autor Tema:  Problemas llamado del procedimiento de mysql en VB.NET  (Leído 2896 veces)

minostalgia

  • Nuevo Miembro
  • *
  • Mensajes: 18
    • Ver Perfil
Problemas llamado del procedimiento de mysql en VB.NET
« en: Lunes 26 de Septiembre de 2011, 15:36 »
0
Problemas llamado del procedimiento de mysql en VB.NET
Hola amigos el foro se ha remodelado y la verdad esta mas chulo un agradecimiento al foro por su colaboracion bueno voy a plantear mi problemas.

Resulta que yo estoy trabajando un sistema en vb.net & Mysql en arquitectura de 3 capas para lo cual tengo las capas ya conociedas por nosotros:

-CapaDatos
-CapaNegocios
-CapaPresentacion

dentro de la capa datos tengo la conexion al mysql y los procedimientos que tiene el mismo bueno cuando hago el llamado del procedimiento me bota un error que me dice la funcion o procedimiento no se ha encontrado en la base de datos o sera que estoy llamandolo mal un ayuda el codigo fuente lo pongo en este link:

http://www.megaupload.com/?d=ZUVNSSO9

Nota esta en version vb.net 2010 para los que no tenga hay un archivo en word que esta todo el codigo fuente y con las capturas de las imegenes cualquier consulta mi correo es: rollerf81@hotmail.com de ante mano gracias

el codigo en mencion

*********CONEXION A LA BASE DE DATOS O CLASE************
Imports MySql.Data.MySqlClient
Public Class Conexion
    Private servidor, database, usuario, password As String
    Public Sub New()
        Try
            servidor = System.Configuration.ConfigurationSettings.AppSettings("servidor").ToString
            database = System.Configuration.ConfigurationSettings.AppSettings("database").ToString
            usuario = System.Configuration.ConfigurationSettings.AppSettings("usuario").ToString
            password = System.Configuration.ConfigurationSettings.AppSettings("password").ToString

        Catch ex As Exception
            'MsgBox(ex, MsgBoxStyle.Critical, "No se pudo Conectar")
        End Try
    End Sub
    Public Function Abrir() As MySqlConnection
        Dim cadena As String
        Dim cn As MySqlConnection
        cadena = "Server=" + servidor + ";" & _
                 "Database=" + database + ";" & _
                 "User=" + usuario + ";" & _
                 "Password=" + password + ";"
        cn = New MySqlConnection(cadena)
        cn.Open()
        Return cn
    End Function
End Class


****************MAPEO DE DATOS***********************
Public Class Alumnos
    Private M_Id_Alu As String
    Private M_Nombre As String
    Private M_Apellidos As String
    Private M_Fecnac As String
    Private M_Direccion As String
    Private M_Telefono As String
    Private M_Instrumento As String
    Private M_Estado As String
    Public Property IdAlu() As String
        Get
            Return M_Id_Alu
        End Get
        Set(ByVal value As String)
            M_Id_Alu = value
        End Set
    End Property
    Public Property Nombre() As String
        Get
            Return M_Nombre
        End Get
        Set(ByVal value As String)
            M_Nombre = value
        End Set
    End Property
    Public Property Apellidos() As String
        Get
            Return M_Apellidos
        End Get
        Set(ByVal value As String)
            M_Apellidos = value
        End Set
    End Property
    Public Property Fecnac() As String
        Get
            Return M_Fecnac
        End Get
        Set(ByVal value As String)
            M_Fecnac = value
        End Set
    End Property
    Public Property Direccion() As String
        Get
            Return M_Direccion
        End Get
        Set(ByVal value As String)
            M_Direccion = value
        End Set
    End Property
    Public Property Telefono() As String
        Get
            Return M_Telefono
        End Get
        Set(ByVal value As String)
            M_Telefono = value
        End Set
    End Property
    Public Property Estado() As String
        Get
            Return M_Estado
        End Get
        Set(ByVal value As String)
            M_Estado = value
        End Set
    End Property
    Public Property Instrumento() As String
        Get
            Return M_Instrumento
        End Get
        Set(ByVal value As String)
            M_Instrumento = value
        End Set
    End Property

    Sub New(ByVal IdAlu As String, ByVal Nombre As String, ByVal Apellidos As String, ByVal Fecnac As String, ByVal Direccion As String, ByVal Telefono As String, ByVal Estado As String)
        Try
            M_Id_Alu = IdAlu
            M_Nombre = Nombre
            M_Apellidos = Apellidos
            M_Fecnac = Fecnac
            M_Direccion = Direccion
            M_Telefono = Telefono
            M_Instrumento = Instrumento
            M_Estado = Estado
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Sub New()
    End Sub
End Class


******************CLASE NEGOCIOS*********************

Imports MySql.Data
Imports MySql.Data.MySqlClient
Imports Eco_Datos
Public Class AlumnosNegocios
    Public Function AlumnosListarTodos() As List(Of Alumnos)
        Dim AluMet As New MetodosAlumnos
        Return AluMet.AlumnosListarTodos
    End Function
End Class
************************************************************


****************LLAMANDO AL PROCEDIMIENTO DE ALMACENADO******
Public Function AlumnosListarTodos() As List(Of Alumnos)
        Dim Listado As New List(Of Alumnos)
        Using cn As New MySqlConnection(Conexion)
            Using comand As New MySqlCommand("sp_alumnos", cn)
                comand.CommandType = CommandType.StoredProcedure
                cn.Open()
                Using Lector As MySqlDataReader = comand.ExecuteReader
                    While Lector.Read
                        Dim Alu As New Alumnos
                        Alu.IdAlu = Lector.Item("id_alu")
                        Alu.Nombre = Lector.Item("nombre")
                        Alu.Apellidos = Lector.Item("Apellidos")
                        Alu.Fecnac = Lector.Item("Fec_nac")
                        Alu.Direccion = Lector.Item("Direccion")
                        Alu.Telefono = Lector.Item("Telefono")
                        Alu.Instrumento = Lector.Item("Instrumento")
                        Alu.Estado = Lector.Item("Estado")
                        Listado.Add(Alu)
                    End While
                End Using
            End Using
        End Using
        Return Listado
    End Function

*******************

****************CODIFICANDO EN EL FORMULARIO*************
Imports Eco_Datos
Imports Eco_Negocios
Public Class FRM_MAN_ALUBUS
Dim PosAlu As Integer
Public xidalu, xnombre, xapellidos, xdireccion, xtelefono, xinstrumento As String
Private Sub FRM_ALU_ALBUS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MostrarDatos()
    End Sub

Sub MostrarDatos()
        Dim aluMet As New AlumnosNegocios
        DtgvAlu.AutoGenerateColumns = False
        DtgvAlu.Columns.Clear()
        DtgvAlu.Columns.Add("id_alu", "id_alu")
        DtgvAlu.Columns.Add("nombre", "nombre")
        DtgvAlu.Columns.Add("apellidos", "apellidos")
        DtgvAlu.Columns.Add("direccion", "direccion")
        DtgvAlu.Columns.Add("telefono", "telefono")
        DtgvAlu.Columns.Add("fec_nac", "fec_nac")
        DtgvAlu.Columns.Add("instrumento", "instrumento")
        DtgvAlu.Columns.Add("estado", "estado")

        DtgvAlu.Columns(0).DataPropertyName = "id_alu"
        DtgvAlu.Columns(1).DataPropertyName = "nombre"
        DtgvAlu.Columns(2).DataPropertyName = "apellidos"
        DtgvAlu.Columns(3).DataPropertyName = "fec_nac"
        DtgvAlu.Columns(4).DataPropertyName = "direccion"
        DtgvAlu.Columns(5).DataPropertyName = "telefono"
        DtgvAlu.Columns(6).DataPropertyName = "Instrumento"
        DtgvAlu.Columns(7).DataPropertyName = "Estado"

        DtgvAlu.DataSource = aluMet.AlumnosListarTodos

    End Sub
End class

 

El app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
  <appSettings >
    <add key ="servidor" value ="localhost"/>
    <add key ="Database" value ="datos"/>
    <add key ="usuario" value ="root"/>
    <add key ="password" value ="soledad"/>
  </appSettings>
</configuration>

ERROR:
Procedure or function "SPU_AlumnosSelectAll" cannot be found in  database

« última modificación: Lunes 26 de Septiembre de 2011, 17:39 por minostalgia »

gabio2

  • Miembro MUY activo
  • ***
  • Mensajes: 402
  • Nacionalidad: mx
    • Ver Perfil
Re:Problemas llamado del procedimiento de mysql en VB.NET
« Respuesta #1 en: Lunes 26 de Septiembre de 2011, 15:53 »
0
Hola que tal, yo estoy en mi trabajo y tengo bloqueadas muchas páginas entre ellas MegaUpload, así que si puedes pegar  el método donde te sale el error, así como tambien copiando el error completo y marcando la línea en la que te lo marca probablemente te pueda ayudar, saludos. :)
@gabio87