SQLDataSource Parameter Problem

  • Thread starter Thread starter Joe
  • Start date Start date
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
 
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
 
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
 
I should also point out that this code is from a web application and
not a Windows desktop client application
 
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
 
Back
Top