473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Parameterized Query expects parameter @Company, which was not supplied.

I am trying to pass a parameter to dynamically populate drop down list. I am not able to pass the parameter from my .aspx file. Here is the grid view and related ObjectDataSource. In srcLocation, the Company paramter being passed is blank or null, if I put default value (hardcoding what is expected), the page display fine when I click on edit button. But with no default value it gives above error.

<asp:GridView
id="grdCAPAs"
DataSourceID="srcCAPAs"
DataKeyNames="CAPA_Number"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true"
AutoGenerateColumns="false"
CssClass="products"
GridLines="none"
Runat="server" >
<Columns>
<asp:BoundField
DataField="CAPA_Number"
ReadOnly="true"
HeaderText="CAPA Number" />
<asp:TemplateField HeaderText="Company" >
<ItemTemplate>
<%#Eval("Company", "{0}")%>
</ItemTemplate>

<EditItemTemplate>
<asp:DropDownList
ID = "ddlCompany"
DataSourceID = "srcCompany"
DataTextField="C9_Company"
DataValueField = "C9_Company"
SelectedValue = '<%# Bind("Company", "{0}") %>'
Runat = "server"
Autopostback = "true" />

</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Location" >
<ItemTemplate>
<%#Eval("Location", "{0}")%>
</ItemTemplate>

<EditItemTemplate>
<asp:DropDownList
ID = "ddlLocation"
DataSourceID = "srcLocation"
DataTextField="C9_Location"
DataValueField = "C9_Location"
SelectedValue = '<%# Bind("Location", "{0}") %>'
Runat = "server" />

</EditItemTemplate>
</asp:TemplateField>

<asp:BoundField
DataField="Area"
HeaderText="Area" />


<asp:ObjectDataSource
id="srcCAPAs"
TypeName="CAPAs.BLL.MaintainCAPA"
SelectMethod="SelectAll"
UpdateMethod="Update"
InsertMethod="Insert"
DeleteMethod="Delete"
Runat="server" />

<asp:ObjectDataSource
id = "srcCompany"
TypeName="CAPAs.BLL.MaintainCAPA"
SelectMethod="SelectCompany"
Runat = "server" />

<asp:ObjectDataSource
id = "srcLocation"
TypeName="CAPAs.BLL.MaintainCAPA"
SelectMethod="SelectLocation"

Runat = "server" >
<SelectParameters>
<asp:ControlParameter ControlID="grdCAPAs" Name = "Company" PropertyName ="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>


Public Shared Function SelectLocation(ByVal Company As String)
Dim daLayer As DAL1 = New DAL1()
Return daLayer.SelectAllLocation(Company)
End Function


Public Function SelectAllLocation(ByVal Company As String) As SqlDataReader
'Create Connection
Dim con As New SqlConnection(_connectionString)

'Create Command
Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = con
cmd.CommandText = "SELECT DISTINCT C9_LOCATION FROM CAPA_LOCATION WHERE C9_COMPANY = @Company"
'Add parameters
cmd.Parameters.AddWithValue("@Company", Company)

'Return DataReader
con.Open()
Return cmd.ExecuteReader(CommandBehavior.CloseConnection)
End Function

Let me know what you think
May 3 '07 #1
0 5899

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Senthil | last post by:
Hi, I created a stored procedure in the sql server. I try to insert a record from the aspx page. But I keep getting this error, "procedure expects parameter <@firstname>, which was not...
8
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: ...
1
by: jfturcott | last post by:
Prepared statement '(@p1 int,@p2 tinyint,@p3 varchar(8000),@p4 varchar(8000),@p5 bit' expects parameter @p1, which was not supplied. I get the above error when trying to update a datagridview to...
0
by: BenCoo | last post by:
Hello colleagues, I have a ObjectDataSource wich is linked to a SQL Server 2005 database I a gridview I have data and on each row a "Edit button" wich wil show the selected record in editmode....
3
by: xlar54 | last post by:
Is there a way to see the exact SQL being generated from a parameterized query? I am using this technique but am getting some strange SQL errors during execution and I would like to see the final...
7
by: Cirene | last post by:
I have a stored procedure named insertcompany. I keep getting the error: Sys.webforms.pagerequestmanagerservererrorexception: Procedure or function 'InsertCompany' expects parameter...
2
by: mcalex | last post by:
Hi, I'm having trouble trying to populate a list box with data from a parameterized query. If I set the rowsource property to the query name, when the form opens I get the parameter values dialog,...
1
by: dragos42 | last post by:
m from Romania and I bought the book let yourself, bother with a problem to conduct script 14.2 appear: The file has been uploaded! Warning: mysqli_query() expects parameter 1 to be mysqli,...
3
BRawn
by: BRawn | last post by:
Hi, I'm writing an application which needs SQL parameters to be passed, and even though I've assigned parameters to the stored procedure, I keep getting the following error message from the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.