Error: - Specified argument was out of the range of valid values. Parameter name: value

Can anyone help me, I am getting the following error whilst attempting to retrieve data from an Access DB:

Specified argument was out of the range of valid values. Parameter name: value
I receive this error from a method which uses a select statement to retrieve data into a datareader, and then I place the value of each of the columns into variables.
I have another method before this one which is identical, except for the select statement, and it gives me no errors at all.
Here is my code:

'create the connection string objects
Dim connstr As String
connstr = ConfigurationSettings.AppSettings("ConnectionString")
'create the select statement
Dim SQL As String = "Select * from ProcessingInput Where ProdID = " & ID & ""
'create the connection object
Dim Conn As New OleDbConnection(connstr)
'create the command objects, passing in the select statements & the connection
Dim Cmd As New OleDbCommand(SQL, Conn)
'create the datareader object
Dim dataReader As OleDbDataReader
Try
'open the connection
Conn.Open()
dataReader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
'iterate through the datareader setting the values of the fields to be the appropriate variable
While dataReader.Read()
HoggFrom = dataReader("HOGGSizeFrom")
HoggTo = dataReader("HOGGSizeTo")

End While
Page.DataBind()
'close the connection
Conn.Close()
Catch ex As Exception
'catch any exception and display the error panel with a related message displaying
error_occurred = True
error_string = ex.Message

End Try
Return error_occurred
Return error_string

0
silversalmon
7/7/2004 12:36:07 AM
asp.net.web-forms 93655 articles. 3 followers. Follow

4 Replies
777 Views

Similar Articles

[PageSpeed] 23

check if your prodid is string or numeric.

if your ProdID is numeric it should be :
Dim SQL As String = "Select * from ProcessingInput Where ProdID = " & ID 

and if it is a string it should be :
Dim SQL As String = "Select * from ProcessingInput Where ProdID = ' " & ID & " ' "

also, use Parameterized Queries to avoid sql injection attacks. tht will also sort out few of the problems you might face otherwise.
hth
***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
7/7/2004 5:02:25 AM
thanks for the reply  - my ProdID is numeric and I tried changing from 


Where ProdID = " & ID & ""

to this

Where ProdID = " & ID

I thought it may be worth a try!! - but no luck.....
I am not sure that I understand how to use a parameterised query - I have heard of them, but not used them before - what are the advantages of using one??
Thanks again.

0
silversalmon
7/7/2004 5:42:56 AM
What is the ID that you are specifying 

Do you have record for that ID??

Sushila Bowalekar Patel
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb
0
SushilaSB
7/7/2004 1:30:14 PM
The ID that I am specifiying in this case is "1". I have a record in the DB for that ID.

Here is my code for the method which gets info from the SalesInput table, prior to calling the method which is giving me the error

Public Function GetSalesDetails()
'Function to get the data related to the product we are viewing from the db
'create the connection string objects
Dim connstr As String
connstr = ConfigurationSettings.AppSettings("ConnectionString")
'create the select statement
Dim SQL As String = "Select * from SalesInput Where ProdID = " & ID & ""
'create the connection object
Dim Conn As New OleDbConnection(connstr)
'create the command objects, passing in the select statements & the connection
Dim Cmd As New OleDbCommand(SQL, Conn)
'create the datareader
Dim dataReader As OleDbDataReader
Try
'open the connection
Conn.Open()
dataReader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
'iterate through the datareader setting the values of the fields to be the appropriate variable
While dataReader.Read()
Code = dataReader("ProdCode")
Desc = dataReader("ProdDesc")
Details = dataReader("Details")
Brand = dataReader("Brand")
ProdLine = dataReader("ProdLine")
ProdSite = dataReader("Site")
Location = dataReader("Location")
Chilled = dataReader("Chilled")
Frozen = dataReader("Frozen")
Customer = dataReader("Customer")
WeightRangeFrom = dataReader("WeightRangeFrom")
WeightRangeTo = dataReader("WeightRangeTo")
SealingMethod = dataReader("SealingMethod")
Air = dataReader("AirPackaging")
Road = dataReader("RoadPackaging")
TargetWeightCtn = dataReader("TargetWeightCarton")
PiecesPerCtn = dataReader("PiecesPerCarton")
PacksPerCtn = dataReader("PacksPerCarton")
PackingMethod = dataReader("PackingMethod")
Weight = dataReader("Weight")
TargetWeight = dataReader("TargetWeight")
PiecesPerPack = dataReader("PiecesPerPack")
Weight2 = dataReader("Weight2")
RequestedBy = dataReader("RequestedBy")
RoadCode = dataReader("RoadCode")
RoadUOM = dataReader("RoadUOM")
RoadDesc = dataReader("RoadDesc")
RoadInvoice = dataReader("RoadInv")
RoadDiscType = dataReader("RoadDiscType")
RoadDisc = dataReader("RoadDisc")
RoadNet = dataReader("RoadNet")
AirCode = dataReader("AirCode")
AirUOM = dataReader("AirUOM")
AirDesc = dataReader("AirDesc")
AirInvoice = dataReader("AirInv")
AirDiscType = dataReader("AirDiscType")
AirDisc = dataReader("AirDisc")
AirNet = dataReader("AirNet")
End While
Page.DataBind()
'close the connection
Conn.Close()
Catch ex As Exception
'catch any exception and display the error panel with a related message displaying
error_occurred = True
error_string = ex.Message
End Try
Return error_occurred
Return error_string
End Function

After this method, I call FillSalesInput() which does the following:

Sub FillSalesInput()
'set all of the input elements to the values just fetched
productCode_txt.Text = Code
prodDesc_txt.Text = Desc
details_txt.Text = Details
brand_dd.SelectedValue = Brand
prod_dd.SelectedValue = ProdLine
site_dd.SelectedValue = ProdSite

GetSalesDetails() and FillSalesInput() work fine, but it is the GetProcessingDetails() method that causes the problem.
Here is GetProcessingDetails():

Public Function GetProcessingDetails()
'Function to get the data related to the product we are viewing from the db
'create the connection string objects
Dim connstr As String
connstr = ConfigurationSettings.AppSettings("ConnectionString")
'create the select statement
Dim SQL As String = "Select * from ProcessingInput Where ProdID = " & ID
'create the connection object
Dim Conn As New OleDbConnection(connstr)
'create the command objects, passing in the select statements & the connection
Dim Cmd As New OleDbCommand(SQL, Conn)
'create the datareader
Dim dataReader As OleDbDataReader
Try
'open the connection
Conn.Open()
'create the datareader
dataReader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
'iterate through the datareader setting the values of the fields to be the appropriate variable
While dataReader.Read()
HoggFrom = dataReader("HOGGSizeFrom")
HoggTo = dataReader("HOGGSizeTo")
FleshColour = dataReader("FleshColour")
SaltContent = dataReader("SaltContent")
DarkMuscle = dataReader("DarkMuscle")
Skin = dataReader("Skin")
Pellicle = dataReader("Pellicle")
Fin = dataReader("Fin")
Collar = dataReader("Collarbone")
Belly = dataReader("BellyFlapTrimmed")
Fat = dataReader("FatRemoved")
GapingDepth = dataReader("GapingDepth")
GapingLength = dataReader("GapingLength")
DarkBruises = dataReader("DarkBruises")
Colouring = dataReader("Colouring")
BloodSpots = dataReader("BloodSpots")
SliceThickness = dataReader("SliceThickness")
FilletShape = dataReader("FilletShape")
UBFrozen = dataReader("UBFrozen")
UBChilled = dataReader("UBChilled")
Ingredients = dataReader("Ingredients")
LabourCost = dataReader("LabourCost")
RecoveryCost = dataReader("Recovery")
End While
Page.DataBind()
'close the connection
Conn.Close()
Catch ex As Exception
'catch any exception and display the error panel with a related message displaying
error_occurred = True
error_string = ex.Message

End Try
Return error_occurred
Return error_string
End Function

Any ideas???
0
silversalmon
7/7/2004 11:00:54 PM
Reply:

Similar Artilces:

Forum Module critical error: The added or subtracted value results in an un-representable DateTime. Parameter name: value
I added a Forum module to a pane.  After I update the Settings, I get this error: A critical error has occurred.The added or subtracted value results in an un-representable DateTime. Parameter name: value Even if I don't change any of the parameters and simply click on the "Update" link on the Setting page, I get this error. Does anybody know what causes this and how to fix it?  Any suggestion is greatly appreciated.  Thanks. What language are you using in your sql server. Other languages than us-english might cause different date representations,...

Value cannot be null. Parameter name: value
I've been running the binary release of 0.95 for a week or so without any problems, but today it's started giving errors when visiting a post. See http://graemef.com/blog/archive/2004/01/15/453.aspx for an example (and stack)... Two things I did today: 1. Change the server time zone in my web.config file 2. Set new posts to be unpublished by default I'll have a look and see if I can figure out what's going on, but I won't have time until the weekend so I thought I'd mention it here too :) Cheers, G.Graeme Foster http://graemef.com Just touch (ie, edit something) in yo...

TabControl-TabCollection error
I have a TabContainer on a aspx page with 1 TabPanel... Then 0 to 4 more TabPanels are added to the TabCollection before sending to the browser from code behind. All tabs appear, display content and behave OK.  I have a button (Regular asp PostBack) OUTSIDE of the TabContainer... When this button attempts postback I get the error - argument was out of the range of valid values... in the TabColleciton... appears to not know I had 1 to 4 more TabPanels.  In the event the page does not any additional TabPanels added from code, this button and others outside of th...

Error: Parameter x value missing a value
Hi frens, I am new to SSRS 2005. I am getting an annoying error Parameter x value missing a value. while generating in the browser. the same report works fine in SSRS report manager.Error Sit: i have a web application where user selects 4 categories like plants,crops,products,regions(these categories are filled in list boxes).After selecting them, I am passing the list items in a list collection,storing in a session and passing it to report viewer page which opens in a new window.thing is when I select only one item under region category the report works fine,but if i select multip...

Error embedding name/value pairs in web.sitemap (& causes error?)
Below is the error I am receiving, how do I tell the parser to NOT treat & as an entity?: Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: The XML sitemap config file Web.links.sitemap could not be loaded. An error occurred while parsing EntityName. Line 60, position 74. Source Error: Line 58: title="Industrial Committee of Ammunition Producers" Line 5...

Passing Values from a Web Form to Another Web Form
Hello All! I am trying to pass values from one web form to another web form. I know that there are 3 ways of doing this: queryString, Server.Transfer and Session. I am using the Server.Transfer method. But I am not able to create, in my 2nd web form, an instance of my 1st web form. My 1st Web form is named CallTrack.aspx and my 2nd is named Export.aspx. What I mean is something like this: Public value as CallTrack. I can't create it in my 2nd web form because when the intellisense is displayed, there's no CallTrack in the options. Thanks!   How about using cross-...

Setting the Parameter Value to the Property Value of a Web Control
I want to filter my DetailsView with a declarative parameter. In my case, I am setting the SqlDataSource's parameter values based on the value of 2 TextBox controls on the page. I have a SP that does a SELECT based on 1 of the parameters passed in (either an ID or phone number). Param Name          Value MemberID          TextBox1.Text Phone               TextBox2.Text I want to assign a default value of 'null' for b...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

If Not value or value then....
Hi all,I want to write a simple IF Not then statement in ASP.net 2.0 and I would like some help please.  If Not ntuser = "DOMAIN\ntuser" Or ntuser = "DOMAIN\ntuser2" Then Panel1.Visible = False End If Doesnt work, can you tell me where i'm going wrong please?many thanks.  The first place you're going wrong is in telling us it "doesn't work" without providing any details. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. Use Not as stated below. It ...

can I get value from Web.config and use the value as a parameter?
in my orginal program code        internal static void QueryForExportAgent(ref StringBuilder sb,decimal MasterKey)     {      sb.Append("SELECT * FROM ZT_Detail WHERE ");      sb.Append(fMasterKey);      sb.Append("=");      sb.Append(setParametersValidation(MasterKey));      sb.Append(" AND ");      sb.Append(fTYPE);  ...

=null; ----> "Value cannot be null. Parameter name: value"
That's what I get if I try to: HttpContext.Current.Cache["foo"] = null; And obviously, it's not the only possible case. So, my question is: what's a problem? :) Is it only objects I cannot assign "null" to? Or is it wrong attempt anyhow, trying to assign "null"? And to make it null what do I do? Do I have to destroy an object somehow? Correct me, please, if I'm wrong. Ok, I found that I can use method "Remove" on cached object so it'll become "null". Most (or all) objects can be assign with "null" like this: myObj = ...

Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: value
I really need help on this. I have a aspx page, I am able to open that page. After entering the value in the text box like aid123 and clicked on the search button it throws this error message and after 2 min if I try the request again with the same value (aid123) it return the results without any error. This search button is calling awebservice which returns the dataset (resultset) Server Error in '/' Application.-------------------------------------------------------------------------------- Value cannot be null. Parameter name: value Description: An unhandled exception occurred during t...

Error: Value cannot be null. Parameter name: encryptedData
Value cannot be null. Parameter name: encryptedData Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: encryptedDataSource Error: Line 121: registryBytes = CType(regKey.GetValue(keyName), Byte()) Line 122: Line 123: Return Encoding.Unicode.GetString(ProtectedData.Unprotect(registryBytes)) Line 124: '&...

passing values to .net web form application
Hi Can any explain me abt how to pass values to my .NET web form application (designed using PB 11.1) from other web application? My intension is to redirect from a web application (ASP.NET to .net web form application) to my web application with user information. Thanks & Regards, Anbazhagan From the "Deploying Applications and Components to .NET" manual: >>> Starting an application with command line parameters If your application requires command line parameters, you can assign values to the PBCommandParm global property before you deploy the...

My datagrid received error: Value cannot be null. Parameter name: dataSet
Hi experts,    To retrieve the data for my datagrid, I have to retrieve a DataSet containing the results from a stored procedure sp_ZipCode_FindCities which contains 2 parameters: CREATE Procedure sp_ZipCode_FindCities (  @ZipCode Numeric(5, 0) = Null,  @Miles Float )As I test it in SQL Server by: exec sp_ZipCode_FindCities '60515','20'It returns 36 records, but I got error at filling the dataset [ adpt.Fill(ds, "CityList_Results")] in visual studio. Can someone point me out where did I do wrong?  Thank you. --------------------------------------...

Web resources about - Error: - Specified argument was out of the range of valid values. Parameter name: value - asp.net.web-forms

Chicago police will add more body cameras following shooting of Laquan McDonald
(Reuters) – City leaders in Chicago on Sunday announced expansion of the police department’s body-worn camera program in the wake of a murder ...

What Did Cards Against Humanity Do With Their Black Friday Profits?
On Black Friday, Cards Against Humanity created a campaign where they sold absolutely nothing for $5. Cards Against Humanity is company that ...

Deadspin Up All Night: Bitch You Better Off Voting For Donald Trump
Thank you for your continued support of Deadspin. As you were. Read more...

EU, Turkey sign deal to stem migrant flows
Xinhua EU, Turkey sign deal to stem migrant flows Xinhua The European Council President Donald Tusk addresses a joint press conference with ...

Amazon gives a closer look at Prime Air drones
It seems that Amazon is really itching to get its Prime Air drone powered deliver service to the skies while still hampered by regulations that ...

Pope to end Africa trip with mosque visit in besieged enclave
By Joe Bavier BANGUI (Reuters) - Pope Francis, ending a three-nation African tour, on Monday visits a mosque in a besieged Muslim enclave in ...

Kobe Bryant bypasses conventional media with retirement announcement
Kobe Bryant. (AP photo) Will he or won’t he? In recent months, mainstream sports outlets have spilled barrels of ink (and a profusion of pixels) ...

Chasing Endorsements, Chris Christie Showers New Hampshire With Calls and Texts
New York Times Chasing Endorsements, Chris Christie Showers New Hampshire With Calls and Texts New York Times MANCHESTER, N.H. — The pleading ...

New Photos Of Princess Charlotte Released By William And Kate As Thank You To Media For Allowing The ...
New photos of Princess Charlotte, the fourth in line to the British throne, have been released by Kensington Palace as a “thank you” to the media ...

Hunt on for mother of baby buried alive
New York Post Hunt on for mother of baby buried alive Toledo Blade COMPTON, Calif. — Authorities are looking for the mother of a newborn baby ...

Resources last updated: 11/30/2015 2:18:57 AM