SQLDataSource Parameter Problem

J

Joe

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
 
E

Eliyahu Goldin

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 said:
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
 
J

Joe

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 said:
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 said:
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
 
J

Joe

I should also point out that this code is from a web application and
not a Windows desktop client application
 
E

Eliyahu Goldin

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 said:
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 said:
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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top