Foros del Web » Programación para mayores de 30 ;) » .NET »

SqlParameter, SqlCommand ¿Qué tengo mal? VB.NET

Estas en el tema de SqlParameter, SqlCommand ¿Qué tengo mal? VB.NET en el foro de .NET en Foros del Web. Código: Private objCN As SqlConnection Private objDA As SqlDataAdapter Private objPar As SqlParameter Private objCMD As SqlCommand Private tbDatos As DataTable Private Sub btnDatos_Click(ByVal sender ...
  #1 (permalink)  
Antiguo 07/10/2005, 17:55
 
Fecha de Ingreso: junio-2003
Ubicación: Asturias
Mensajes: 2.429
Antigüedad: 20 años, 10 meses
Puntos: 7
SqlParameter, SqlCommand ¿Qué tengo mal? VB.NET

Código:
    Private objCN As SqlConnection
    Private objDA As SqlDataAdapter
    Private objPar As SqlParameter
    Private objCMD As SqlCommand

    Private tbDatos As DataTable
    Private Sub btnDatos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDatos.Click
        Try
            objCN = New SqlConnection("workstation id=localhost;packet size=4096;user id=sa; password=clave;data source=CARLOS;persist security info=False;initial catalog=bdMSN")

            objCMD = New SqlCommand("PDameContactos", objCN)

            objPar = New SqlParameter("@clienteID", CInt(3))
            objPar.SqlDbType = SqlDbType.Int
            objPar.Direction = ParameterDirection.Input

            objCMD.Parameters.Add(objPar)

            objDA = New SqlDataAdapter(objCMD)

            tbDatos = New DataTable
            objDA.Fill(tbDatos)

            dgDatos.DataSource = tbDatos
            dgDatos.ReadOnly = True
            dgDatos.Refresh()
        Catch ex As SqlException
            MsgBox(ex.Message)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
La excepción que me sale es la siguiente:

"Sintaxis incorrecta cerca de 'PDameContactos' ". El parametro se llama tal y como está puesto y el Procedimiento almacenado también esta bien puesto.

¿Alguien sabe que puede ser? Gracias
__________________
Charlie.
  #2 (permalink)  
Antiguo 07/10/2005, 18:03
 
Fecha de Ingreso: junio-2003
Ubicación: Asturias
Mensajes: 2.429
Antigüedad: 20 años, 10 meses
Puntos: 7
jder k tonto soy, me me olvido poner la línea:

objCMD.CommandType = CommandType.StoredProcedure
__________________
Charlie.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:20.