Hi, I'm trying since a few days make work a gridview binded to sqldatasource. I've read a lot of posts and I'm not achieving it. The last exception I've obtained:
System.Data.SqlClient.SqlException: @@idusuario is not a parameter for procedure Select_Vectores.
en System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
en System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
en System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
en
when I try to bind the GV.
But my procedure is this:
ALTER PROCEDURE [dbo].[Select_Vectores]
@idusuario integer = null
AS
DECLARE @sql nvarchar(MAX),
@paramlist nvarchar(4000)
SELECT @sql =
'SELECT tbV.NUMVECTOR, tbV.DESCRIPCION, 0[Dummy1], 0[Dummy2] FROM tbVECTORES tbV WHERE 1 = 1'
IF @idusuario IS NOT NULL
SET @sql = @sql + ' AND tbV.ID_USUARIO = @xidusuario '
set @paramlist = '@xidusuario integer'
EXEC sp_executesql @sql, @paramlist, @idusuario
SET NOCOUNT ON
RETURN
I'm adding the parameters on code behind. I should load the GV when the page it's loaded:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("MST_IDUSUARIO") = 4
If Not Page.IsPostBack Then
verVector()
ElseIf Not Page.IsPostBack And Radio1.InputAttributes("checked") = "true" Then 'And Radio1.Checked'
verVector()
ElseIf Not Page.IsPostBack And Radio3.InputAttributes("checked") = "true" Then 'And Radio3.Checked'
verBuzon()
ElseIf Page.IsPostBack And Radio1.InputAttributes("checked") = "true" Then 'And Radio1.Checked'
verVector()
ElseIf Page.IsPostBack And Radio3.InputAttributes("checked") = "true" Then 'And Radio3.Checked'
verBuzon()
Else
'Falta por implementar Radio2'
End If
End Sub
Public Sub verVector()
Try
SDSVector.SelectParameters.Add("@idusuario", Session("MST_IDUSUARIO"))
SDSVector.Select(DataSourceSelectArguments.Empty)
gvVector.DataBind()
vectorVisible()
Catch exsql As SqlException
lblErrorVisible()
Me.lblError.Text = exsql.ToString()
Catch ex As Exception
lblErrorVisible()
Me.lblError.Text = ex.ToString()
End Try
End Sub
What I'm doing wrong? any idea? I'm obtainning the exception on this line:
gvVector.DataBind()
Thanks!
Ever than a programmer makes an extra hour god kills a kitten
Member
233 Points
766 Posts
System.Data.SqlClient.SqlException: @@idusuario on SqlDataSource
Jul 04, 2012 06:49 AM|kilofafeure|LINK
Hi, I'm trying since a few days make work a gridview binded to sqldatasource. I've read a lot of posts and I'm not achieving it. The last exception I've obtained:
when I try to bind the GV.
But my procedure is this:
I'm adding the parameters on code behind. I should load the GV when the page it's loaded:
My aspx:
My codebehind:
What I'm doing wrong? any idea? I'm obtainning the exception on this line:
Thanks!
Member
233 Points
766 Posts
Re: System.Data.SqlClient.SqlException: @@idusuario on SqlDataSource
Jul 04, 2012 06:53 AM|kilofafeure|LINK
Here was the error:
It should be
All-Star
94130 Points
18109 Posts
Re: System.Data.SqlClient.SqlException: @@idusuario on SqlDataSource
Jul 05, 2012 09:45 PM|Decker Dong - MSFT|LINK
Congratulation that your problem is solved!Welcome to our forum next time to share more good things or ideas……
Reguards!