473,795 Members | 3,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 ObjectDataSourc e. 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="s rcCAPAs"
DataKeyNames="C APA_Number"
AutoGenerateEdi tButton="true"
AutoGenerateDel eteButton="true "
AutoGenerateCol umns="false"
CssClass="produ cts"
GridLines="none "
Runat="server" >
<Columns>
<asp:BoundFie ld
DataField="CAPA _Number"
ReadOnly="true"
HeaderText="CAP A Number" />
<asp:TemplateFi eld HeaderText="Com pany" >
<ItemTemplate >
<%#Eval("Compan y", "{0}")%>
</ItemTemplate>

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

</EditItemTemplat e>
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Loc ation" >
<ItemTemplate >
<%#Eval("Locati on", "{0}")%>
</ItemTemplate>

<EditItemTempla te>
<asp:DropDownLi st
ID = "ddlLocatio n"
DataSourceID = "srcLocatio n"
DataTextField=" C9_Location"
DataValueField = "C9_Locatio n"
SelectedValue = '<%# Bind("Location" , "{0}") %>'
Runat = "server" />

</EditItemTemplat e>
</asp:TemplateFie ld>

<asp:BoundFie ld
DataField="Area "
HeaderText="Are a" />


<asp:ObjectData Source
id="srcCAPAs"
TypeName="CAPAs .BLL.MaintainCA PA"
SelectMethod="S electAll"
UpdateMethod="U pdate"
InsertMethod="I nsert"
DeleteMethod="D elete"
Runat="server" />

<asp:ObjectData Source
id = "srcCompany "
TypeName="CAPAs .BLL.MaintainCA PA"
SelectMethod="S electCompany"
Runat = "server" />

<asp:ObjectData Source
id = "srcLocatio n"
TypeName="CAPAs .BLL.MaintainCA PA"
SelectMethod="S electLocation"

Runat = "server" >
<SelectParamete rs>
<asp:ControlPar ameter ControlID="grdC APAs" Name = "Company" PropertyName ="SelectedValue " />
</SelectParameter s>
</asp:ObjectDataS ource>


Public Shared Function SelectLocation( ByVal Company As String)
Dim daLayer As DAL1 = New DAL1()
Return daLayer.SelectA llLocation(Comp any)
End Function


Public Function SelectAllLocati on(ByVal Company As String) As SqlDataReader
'Create Connection
Dim con As New SqlConnection(_ connectionStrin g)

'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.ExecuteRead er(CommandBehav ior.CloseConnec tion)
End Function

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

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

Similar topics

1
3232
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 supplied". This is what I am doing. cmd.CommandText = "proc_insertuser"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@firstname", SqlDbType.VarChar, 50);
8
8053
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: WHERE LIKE '" & ASPvar & "' % ORDER BY ... However, my call is similar to: conn.qMyLookup strVar, rs
1
6877
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 the sql database. I am using the commandbuilder because the datagridview can be saving 8 different types of data (to different tables) depending upon the selection made in a Treeview control. The same code without the parameters line works...
0
1594
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. When I click the update button I get this error : Parameterized Query '(@TmprValue float,@TmprRemark nvarchar(4000),@TmprLocationID int' expects parameter @TmprRemark, which was
3
2225
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 SQL that is being generated.
7
1348
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 '@ApptPhone1Required', which was not supplied. But, I DID supply it along with all others.... (here's a snippet) MyCommand.Parameters.AddWithValue("@InstructionsOperator",
2
5086
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, but I want to pass the params from code. If I create a querydef, I can pass the parameter in, but I don't know how to get the records into the listbox. I have tried lstNames = qdfNames.sql lstNames.recordset = qdfNames.OpenRecordset; ...
1
9943
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, resource given in C:\wamp\www\scripts_named\07\add_print.php on line 109 Your submission could not be processed due to a system error. Where wrong? Send script component: mysql_connect.php:
3
1787
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 debugger: 'usp_PopulateManualSelectionForEdit' expects parameter '@BinID', which was not supplied. The stored proc: CREATE PROCEDURE usp_PopulateManualSelectionForEdit
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.