Hi All...
I Came across this error while populating a combobox from
a datatable (I'm working in VB.NET):
Specified argument was out of the range of valid values.
Parameter name: '-1' is not a valid value
for 'index'
code[VB]
Private Sub PopulatePrManag erCombo()
' This procedure populates the combo box on the
' form with a list of Project Manager from the
' Dms database.
Dim cnSQL As MySqlConnection
Dim cmSQL As MySqlCommand
Dim drSQL As MySqlDataReader
Dim strSQL As String
Dim objListItem As ListItem
Try
' Build Select statement to query Project Manager Name from the Staff
' table.
strSQL = "SELECT tbl_staffs.stf_ first_name, " _
& " tbl_staff_assig nments.sta_staf f_id_fk " _
& " FROM tbl_staffs ,tbl_staff_assi gnments " _
& " WHERE tbl_staffs.stf_ staff_id_pk = tbl_staff_assig nments.sta_staf f_id_fk " _
& " AND tbl_staff_assig nments.sta_cate gory_id_fk = 1 order by tbl_staffs.stf_ first_name"
cnSQL = New MySqlConnection
cnSQL.Connectio nString = connect.Connect ionString
cnSQL.Open()
cmSQL = New MySqlCommand(st rSQL, cnSQL)
drSQL = cmSQL.ExecuteRe ader()
cboPrMgr.Items. Clear()
' Loop through the result set and add the category
' names to the combo box.
Do While drSQL.Read()
objListItem = New ListItem(drSQL. Item("stf_first _name").ToStrin g(), _
Convert.ToInt32 (drSQL.Item("st a_staff_id_fk") ))
cboPrMgr.Items. Add(objListItem )
Loop
' Close and Clean up objects
drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
Catch e As MySqlException
MsgBox("To run this sample you must have MySql Access" & _
" For instructions on " & _
"installing contact Admin.", MsgBoxStyle.Cri tical, _
"MySql not found")
' Quit program if connection method was not successful.
'End
Catch e As Exception
MsgBox(e.Messag e, MsgBoxStyle.Cri tical, "General Error")
End Try
End Sub
plz help me out...
thnx n regards
hepsi..
6 3683
Did you get a line number for that error?
Did you get a line number for that error?
Hii,
The error must be at :
[ERROR]
cmSQL.Parameter s.Add("?Pr_Mana gerID", CType(cboPrMgr. Items(cboPrMgr. SelectedIndex), ListItem).ID).. ......[ERROR]
And moreover when im tryign to clear the form:
[vb code]
Private Sub ClearForm()
' Clear the data entry form.
txtPrCode.Text = ""
txtPrLocation.T ext = ""
---------- cboPrMgr.Select edIndex = -1 ---------------------
txtPrStreet.Tex t = ""
cboState.Select edIndex = -1
[/vb code]
cboPrMgr.Select edIndex= -1 ..... i have a doubt here whther this is correct or not???
plz help..
thnx in advance
Why is there a question mark in front of ?Pr_ManagerID? I generally associate -1 with JS have you tried null?
Why is there a question mark in front of ?Pr_ManagerID? I generally associate -1 with JS have you tried null?
Thnx for ur reply...
Yes ive tried null but of no use...
1 thing i observed is: few records are being displayed from the combo bx without this error whereas other records are displaying error message.
Only thing I can think of is that they are not all in the right format. This is the same error "Parameter name: '-1' is not a valid value". Then try and debug, leave out this parameter and see if the page works. After that write out the value to see what you get. HTH.
Only thing I can think of is that they are not all in the right format. This is the same error "Parameter name: '-1' is not a valid value". Then try and debug, leave out this parameter and see if the page works. After that write out the value to see what you get. HTH.
hii,
hey ive done tht tooo...
nw im thinking abt this line...
...objListItem = New ListItem(drSQL. Item("stf_first _name").ToStrin g(), _
Convert.ToInt32 (drSQL.Item("st a_staff_id_fk") ))....
is there any problem here: Convert.ToInt32
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Conroy |
last post by:
Hi... Synposis...
Throws exception:
"Specified argument was out of the range of valid values."
Read on for the juicy tidbits.
MySimpleClassCol mscc=new MySimpleClassCol();
private void InitCombo()
{
|
by: Todd Perkins |
last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually
rely on google. So I hope I have enough info contained. Thank you in
advance for any help!
Problem:
I am getting this error when I try to pull up my edit page to display the
current database information in the form, and then edit it on click:
|
by: subdhar |
last post by:
I'm getting following error in asp.net application.I search the web
and couldn't find error like this can any one help me in trouble with
this error
Specified argument was out of the range of valid values.
Parameter name: U 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.
|
by: darrel |
last post by:
What does this error mean?
Specified argument was out of the range of valid values. Parameter name:
value
System.Web
It's being thrown here:
DDL_SubCategory.Enabled = True
DDL_SubCategory.DataSource = DS
|
by: rajarameshvarma |
last post by:
Hi....
I have a serious problem while deploying my asp.net application. I have
developed a web project in which everypage contains Header, Left
navigation and footer as usercontrols. For center court i have used
Ifrmae tag to call an HTML page. It was working fine for most of the
pages it is working fine. But for some pages...user controls are
rendered correctly ... but htnl page which is in the frame giving
error.
| |
by: IndiraPriyaDarshini |
last post by:
Hi ,
Am trying to sum the total in the footer if a gridview,
but am getting the error "Specified argument was out of the range of valid values.
Parameter name: index "..Its Printing one cell value in the footer..
But for the seond sum,it showing the error, the value is getting,
Help me pls..
Here is the ode snippent
|
by: gsauns |
last post by:
I have a DetailsView which is inside of a FormView. I lifted this
DetailsView straight off another one of my pages, where it was working
beautifully. Now I get this endlessly frustrating error message
whenever I try to go into Edit mode:
Specified argument was out of the range of valid values.
Parameter name: index
The DetailsView is actually inside an UpdatePanel, which is inside an
Ajax Accordion, which is inside the FormView. Could...
|
by: Chapi |
last post by:
hi, i'm having problems with a datagrid paging.
it's populates fine, but when i click the paging button appears this
error:"Specified argument was out of the range of valid
values.Parameter name: index"
I paste the code here in case someone can help me.
Sub paginaNueva(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
|
by: RN1 |
last post by:
I have a DataGrid with 7 BoundColumns. A user can login as an admin or
non-admin. When a user logs in as a non-admin & the DatGrid is in the
editable mode, I want only the first 4 columns i.e. the TextBoxes in
the first 4 columns to be editable & the remaining 3 TextBoxes should
remain disabled. This is what I tried (in the OnItemDataBound event
functions):
--------------------
If (sessAdmin = 0) Then
For i = 4 To 6
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |