Ver Mensaje Individual
  #7 (permalink)  
Antiguo 30/06/2011, 03:43
JrScaletta
 
Fecha de Ingreso: junio-2011
Mensajes: 18
Antigüedad: 12 años, 11 meses
Puntos: 0
Respuesta: Resultado SQLDataSource en variable

Gracias ramirezmario7, con todo lo perdido que iba, me voy haciendo una idea seria. Hoy me he vuelto a poner manos a la obra. Os detallo lo que tengo:

Stored procedure en SQL
Código:
USE [trackpaso]
GO
/****** Object:  StoredProcedure [dbo].[prueba]    Script Date: 06/30/2011 10:43:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[prueba]

as begin

declare @id int
declare @numticket int
declare @changedby int
declare @descripcion varchar(500)
declare @fecha date

set @id = (select next_id from ID_TABLE where ID_TABLE_ID = 19)

insert into TTRAIL values(@id,@numticket,@changedby,@descripcion,@fecha,0)

update id_table set NEXT_ID = @id+1 where ID_TABLE_ID = 19


end
CODE BEHIND ASPX
Código:
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtfecha.Text = Now

        Dim parametro As New System.Data.SqlClient.SqlParameter
        Dim objCommand As New SqlClient.SqlCommand("prueba"), _
    Conexion As String = "server='localhost'; user id='sa'; password='xxxxxxx'; database='trackpaso'"

        objCommand.CommandType = CommandType.StoredProcedure


       
        parametro = New System.Data.SqlClient.SqlParameter
        parametro.ParameterName = "@numticket"
        parametro.Value = CInt(Me.lblNumTick.Text)
        objCommand.Parameters.Add(parametro)

        parametro = New System.Data.SqlClient.SqlParameter
        parametro.ParameterName = "@changedby"
        parametro.Value = 232
        objCommand.Parameters.Add(parametro)

        parametro = New System.Data.SqlClient.SqlParameter
        parametro.ParameterName = "@descripcion"
        parametro.Value = txtcomentario.Text
        objCommand.Parameters.Add(parametro)

        parametro = New System.Data.SqlClient.SqlParameter
        parametro.ParameterName = "@fecha"
        parametro.Value = txtfecha.Text
        objCommand.Parameters.Add(parametro)



        objCommand.Connection = New SqlClient.SqlConnection(Conexion)
        objCommand.Connection.Open()
        objCommand.ExecuteNonQuery()
        objCommand.Connection.Close()


    End Sub
El error que me tira el compilador al intentar añadir un comentario es:

El procedimiento prueba no tiene parámetros y se han proporcionado argumentos.

Este error me lo da en la linea del ExecuteNonQuery.

Gracias por todo!