Friday, March 16, 2012

Parameter problems

The first hit to the page a menu loads with the companys info and their personal menu (Depending on the @dotnet.itags.org.IDCompany passed will depend on what menu is loaded).
After the menu is visual then user clicks a selection from the Hyperlink (The one that is passing the parameters)). and that is where this latest issue is coming into play. Now it is telling me that one of the parameters is not excepted by the sqlcommand (SPROC). "I know what is happening here, the menu is loading and and tring to except both parameters, the reason i know this is becase both of the user controls except the IDCompany; however, only one control excepts the @dotnet.itags.org.IDCompanyProductCategory, that tells me that the menu datalist is loading first because the other menu that excepts both of the parameters would of loaded if was passed the parameters and it can not be pased both unless the menu passes them. Anyway, do i need somesort of If page.is post back? What do you recommend?
Thanks,!!!
Erik...
In other words when i click on the asphyperlink in the datalist call the same page that it resides in; however, this time passing a differ set of parameters... I KNOW this is some sort of post back,,, i just need a little caoching from a pro,,, and please ask your questions if i am not clear on what it is that i am tring to do...
***THIS page will be a page that has lots of controls.... More than the two in question, that is why i am asking for your opition.. :)

Server Error in '/ConstructionSuperCenterCom' Application.
------------------------
An SqlParameter with ParameterName '@dotnet.itags.org.IDCompanyProductCategory' is not contained by this SqlParameterCollection.

================================CODE

PrivateSub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

Dim strErrorAsString

SessionCheck(Session, Request.Cookies("AFCC"), strError)

'GetNotifications(lblNotification, Request)

'If Page.IsPostBack Then

Dim myConnectionAsNew SqlConnection(ConfigurationSettings.AppSettings("cnn"))

Try

'-----------HERE--------

myConnection.Open()

cmdGetBlindCompanyMenuItems.Parameters("@dotnet.itags.org.IDCompany").Value = Request("IDCompany")

' -----------HERE--------

cmdGetBlindCompanyMenuItems.Parameters("@dotnet.itags.org.IDCompanyProductCategory").Value = Request("IDCompanyProductCategory")

cmdGetBlindCompanyMenuItems.Connection = myConnection

'--------

Dim drAs SqlDataReader

dr = cmdGetBlindCompanyMenuItems.ExecuteReader

dlCom16.DataSource = dr

dlCom16.DataBind()

dr.Close()

Finally

myConnection.Dispose()

EndTry

EndSub

EndClass

Hi,
error indicates that no such parameters have been added to the parameters collection.
Before setting these

cmdGetBlindCompanyMenuItems.Parameters("@.IDCompany").Value = Request("IDCompany")

cmdGetBlindCompanyMenuItems.Parameters("@.IDCompanyProductCategory").Value = Request("IDCompanyProductCategory")


You should add the parameter to the Parameters collection (assuming they are integers).
cmdGetBlindCompanyMenuItems.Parameters.Add("@.IDCompany",SqlDbType.Int)
cmdGetBlindCompanyMenuItems.Parameters.Add("@.IDCompanyProductCategory",SqlDbType.Int)
'Set values here or set them inline with the parameter adding/declaration
'...

0 comments:

Post a Comment