SQLDataSource Parameter Problem

Discussion in 'ASP .Net' started by Joe, Aug 13, 2009.

  1. Joe

    Joe Guest

    I am attempting to pass an input parameter to a stored
    procedure, but it keeps telling me that the sp is expecting
    @ESTIMATE_ID, but the parameter is missing. The error occurs on the
    databind statement. What am I doing wrong?


    Private Sub GetEstimateDetails(ByVal iEstimateID As Integer)
    Dim dsEstimateDetail As New SQLDataSource
    Dim cmdSelect As New SqlCommand


    grdvwDetails.DataSource = dsEstimateDetail

    dsEstimateDetail.ConnectionString = cnQuickSizeWeb
    dsEstimateDetail.SelectCommandType =
    SqlDataSourceCommandType.StoredProcedure
    dsEstimateDetail.SelectCommand = "usp_Get_Estimate_Details"
    dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID",
    Data.DbType.Int32, iEstimateID)



    If Not Me.IsPostBack Then
    grdvwDetails.DataBind()
    End If
    End Sub
    Joe, Aug 13, 2009
    #1
    1. Advertising

  2. dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID", Data.DbType.Int32,
    iEstimateID)
    doesn't set the parameter value.

    Use
    dsEstimateDetail.SelectParameters.AddWithValue("@ESTIMATE_ID", iEstimateID)



    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "Joe" <> wrote in message
    news:...
    > I am attempting to pass an input parameter to a stored
    > procedure, but it keeps telling me that the sp is expecting
    > @ESTIMATE_ID, but the parameter is missing. The error occurs on the
    > databind statement. What am I doing wrong?
    >
    >
    > Private Sub GetEstimateDetails(ByVal iEstimateID As Integer)
    > Dim dsEstimateDetail As New SQLDataSource
    > Dim cmdSelect As New SqlCommand
    >
    >
    > grdvwDetails.DataSource = dsEstimateDetail
    >
    > dsEstimateDetail.ConnectionString = cnQuickSizeWeb
    > dsEstimateDetail.SelectCommandType =
    > SqlDataSourceCommandType.StoredProcedure
    > dsEstimateDetail.SelectCommand = "usp_Get_Estimate_Details"
    > dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID",
    > Data.DbType.Int32, iEstimateID)
    >
    >
    >
    > If Not Me.IsPostBack Then
    > grdvwDetails.DataBind()
    > End If
    > End Sub
    >
    > __________ Information from ESET NOD32 Antivirus, version of virus
    > signature database 4330 (20090812) __________
    >
    > The message was checked by ESET NOD32 Antivirus.
    >
    > http://www.eset.com
    >
    >
    >



    __________ Information from ESET NOD32 Antivirus, version of virus signature database 4330 (20090812) __________

    The message was checked by ESET NOD32 Antivirus.

    http://www.eset.com
    Eliyahu Goldin, Aug 13, 2009
    #2
    1. Advertising

  3. Joe

    Joe Guest

    Thank you, but it does not seem to recognize AddWithValue. I get this
    error message:

    'AddWithValue' is not a member of
    'System.Web.UI.WebControls.ParameterCollection'.
    -----------------------------------------------

    Eliyahu Goldin wrote:
    > dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID", Data.DbType.Int32,
    > iEstimateID)
    > doesn't set the parameter value.
    >
    > Use
    > dsEstimateDetail.SelectParameters.AddWithValue("@ESTIMATE_ID", iEstimateID)
    >
    >
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    >
    >
    > "Joe" <> wrote in message
    > news:...
    > > I am attempting to pass an input parameter to a stored
    > > procedure, but it keeps telling me that the sp is expecting
    > > @ESTIMATE_ID, but the parameter is missing. The error occurs on the
    > > databind statement. What am I doing wrong?
    > >
    > >
    > > Private Sub GetEstimateDetails(ByVal iEstimateID As Integer)
    > > Dim dsEstimateDetail As New SQLDataSource
    > > Dim cmdSelect As New SqlCommand
    > >
    > >
    > > grdvwDetails.DataSource = dsEstimateDetail
    > >
    > > dsEstimateDetail.ConnectionString = cnQuickSizeWeb
    > > dsEstimateDetail.SelectCommandType =
    > > SqlDataSourceCommandType.StoredProcedure
    > > dsEstimateDetail.SelectCommand = "usp_Get_Estimate_Details"
    > > dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID",
    > > Data.DbType.Int32, iEstimateID)
    > >
    > >
    > >
    > > If Not Me.IsPostBack Then
    > > grdvwDetails.DataBind()
    > > End If
    > > End Sub
    > >
    > > __________ Information from ESET NOD32 Antivirus, version of virus
    > > signature database 4330 (20090812) __________
    > >
    > > The message was checked by ESET NOD32 Antivirus.
    > >
    > > http://www.eset.com
    > >
    > >
    > >

    >
    >
    > __________ Information from ESET NOD32 Antivirus, version of virus signature database 4330 (20090812) __________
    >
    > The message was checked by ESET NOD32 Antivirus.
    >
    > http://www.eset.com
    Joe, Aug 13, 2009
    #3
  4. Joe

    Joe Guest

    I should also point out that this code is from a web application and
    not a Windows desktop client application
    Joe, Aug 13, 2009
    #4
  5. Right, it is not good for setting data sources.

    You need to pass the @ESTIMATE_ID parameter in the <SelectParameters>
    section on the data source markup. You can put there different sorts of
    parameters depending on where you are getting the value from. You can also
    add in programmatically the the data source's OnSelecting event.


    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://blogs.microsoft.co.il/blogs/egoldin
    http://msmvps.com/blogs/egoldin


    "Joe" <> wrote in message
    news:...
    > Thank you, but it does not seem to recognize AddWithValue. I get this
    > error message:
    >
    > 'AddWithValue' is not a member of
    > 'System.Web.UI.WebControls.ParameterCollection'.
    > -----------------------------------------------
    >
    > Eliyahu Goldin wrote:
    >> dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID", Data.DbType.Int32,
    >> iEstimateID)
    >> doesn't set the parameter value.
    >>
    >> Use
    >> dsEstimateDetail.SelectParameters.AddWithValue("@ESTIMATE_ID",
    >> iEstimateID)
    >>
    >>
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer
    >> Microsoft MVP [ASP.NET]
    >> http://msmvps.com/blogs/egoldin
    >>
    >>
    >> "Joe" <> wrote in message
    >> news:...
    >> > I am attempting to pass an input parameter to a stored
    >> > procedure, but it keeps telling me that the sp is expecting
    >> > @ESTIMATE_ID, but the parameter is missing. The error occurs on the
    >> > databind statement. What am I doing wrong?
    >> >
    >> >
    >> > Private Sub GetEstimateDetails(ByVal iEstimateID As Integer)
    >> > Dim dsEstimateDetail As New SQLDataSource
    >> > Dim cmdSelect As New SqlCommand
    >> >
    >> >
    >> > grdvwDetails.DataSource = dsEstimateDetail
    >> >
    >> > dsEstimateDetail.ConnectionString = cnQuickSizeWeb
    >> > dsEstimateDetail.SelectCommandType =
    >> > SqlDataSourceCommandType.StoredProcedure
    >> > dsEstimateDetail.SelectCommand = "usp_Get_Estimate_Details"
    >> > dsEstimateDetail.SelectParameters.Add("@ESTIMATE_ID",
    >> > Data.DbType.Int32, iEstimateID)
    >> >
    >> >
    >> >
    >> > If Not Me.IsPostBack Then
    >> > grdvwDetails.DataBind()
    >> > End If
    >> > End Sub
    >> >
    >> > __________ Information from ESET NOD32 Antivirus, version of virus
    >> > signature database 4330 (20090812) __________
    >> >
    >> > The message was checked by ESET NOD32 Antivirus.
    >> >
    >> > http://www.eset.com
    >> >
    >> >
    >> >

    >>
    >>
    >> __________ Information from ESET NOD32 Antivirus, version of virus
    >> signature database 4330 (20090812) __________
    >>
    >> The message was checked by ESET NOD32 Antivirus.
    >>
    >> http://www.eset.com

    >
    > __________ Information from ESET NOD32 Antivirus, version of virus
    > signature database 4333 (20090813) __________
    >
    > The message was checked by ESET NOD32 Antivirus.
    >
    > http://www.eset.com
    >
    >
    >



    __________ Information from ESET NOD32 Antivirus, version of virus signature database 4333 (20090813) __________

    The message was checked by ESET NOD32 Antivirus.

    http://www.eset.com
    Eliyahu Goldin, Aug 13, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew
    Replies:
    3
    Views:
    2,870
    Andrew
    Apr 1, 2004
  2. Karl
    Replies:
    2
    Views:
    25,369
  3. Stu
    Replies:
    0
    Views:
    378
  4. Wayne Wengert

    Problem Using GUID as SQLDataSource Parameter

    Wayne Wengert, Feb 5, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    5,738
    Wayne Wengert
    Feb 6, 2006
  5. Jim Andersen
    Replies:
    3
    Views:
    6,964
    Alex D.
    Mar 3, 2006
Loading...

Share This Page