Monday, August 16, 2010

ASP.NET problem:';Parameter @lab not supplied';error even after selectparameters.add called...how do I fix this?

Here's my code, which calls a stored proc named insertlab with two parameters: @lab and @fake. Ways to prevent the error?





%26lt;%


Dim c As Parameter


Dim d As Parameter


c.Name = ';@lab';


c.Type = TypeCode.String


c.DefaultValue = ';trylab';


SqlDataSource2.SelectParameters.Add(c)


d.Name = ';@fake';


d.Type = TypeCode.String


d.DefaultValue = ';trylab';


SqlDataSource2.SelectParameters.Add(d)


%%26gt;


%26lt;form id=';form2'; runat=';server';%26gt;


%26lt;asp:GridView ID=';GridView2'; runat=';server'; AutoGenerateColumns=';True'; DataSourceID=';SqlDataSource2';%26gt;


%26lt;/asp:GridView%26gt;


%26lt;asp:SqlDataSource ID=';SqlDataSource2'; runat=';server'; ConnectionString=';Data Source=X;Initial Catalog=complab;User ID=X;password=X';


ProviderName=';System.Data.SqlClient'; SelectCommand=';insertlab'; SelectCommandType=';StoredProcedure';%26gt;


%26lt;SelectParameters%26gt;


%26lt;/SelectParameters%26gt;


%26lt;/asp:SqlDataSourceASP.NET problem:';Parameter @lab not supplied';error even after selectparameters.add called...how do I fix this?
Its probably because you're not creating an instance of the parameter. Try adding the new keywork when declaring the parameter i.e. Dim c As New SqlParameter. For more information take a look at this web site.





http://www.macronimous.com/resources/cal鈥?/a>





Hope this helps

No comments:

Post a Comment