Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > SQLDataSource Parameter Problem

Reply
Thread Tools

SQLDataSource Parameter Problem

 
 
Joe
Guest
Posts: n/a
 
      08-12-2009
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_I D",
Data.DbType.Int32, iEstimateID)



If Not Me.IsPostBack Then
grdvwDetails.DataBind()
End If
End Sub
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-13-2009
dsEstimateDetail.SelectParameters.Add("@ESTIMATE_I D", Data.DbType.Int32,
iEstimateID)
doesn't set the parameter value.

Use
dsEstimateDetail.SelectParameters.AddWithValue("@E STIMATE_ID", iEstimateID)



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


"Joe" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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_I D",
> 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



 
Reply With Quote
 
 
 
 
Joe
Guest
Posts: n/a
 
      08-13-2009
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_I D", Data.DbType.Int32,
> iEstimateID)
> doesn't set the parameter value.
>
> Use
> dsEstimateDetail.SelectParameters.AddWithValue("@E STIMATE_ID", iEstimateID)
>
>
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
>
>
> "Joe" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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_I D",
> > 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

 
Reply With Quote
 
Joe
Guest
Posts: n/a
 
      08-13-2009
I should also point out that this code is from a web application and
not a Windows desktop client application
 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-13-2009
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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_I D", Data.DbType.Int32,
>> iEstimateID)
>> doesn't set the parameter value.
>>
>> Use
>> dsEstimateDetail.SelectParameters.AddWithValue("@E STIMATE_ID",
>> iEstimateID)
>>
>>
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP [ASP.NET]
>> http://msmvps.com/blogs/egoldin
>>
>>
>> "Joe" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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_I D",
>> > 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SqlDataSource, SQL working, Stored procedure doesn't. Parameter hell Jim Andersen ASP .Net 3 03-03-2006 09:04 PM
Problem Using GUID as SQLDataSource Parameter Wayne Wengert ASP .Net 3 02-06-2006 04:20 PM
using SqlDataSource with parameter that is filled in other control Stu ASP .Net 0 10-07-2005 07:00 PM
Re: How to retrieve an Output Parameter using SQLDataSource Control Karl ASP .Net 2 09-07-2004 10:26 PM
Whidbey(v2.0.31113) OracleClient/SqlDataSource parameter binding Andrew ASP .Net 3 04-01-2004 05:13 PM



Advertisments