473,788 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Index (zero based) must be greater than or equal to zero

304 Contributor
hi,
When i try to select the number of rows in my table depending on a where condition i get this error : -

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

my select statement is like this:-

Expand|Select|Wrap|Line Numbers
  1. Dim con As New MySqlConnection(ConfigurationManager.AppSettings("connectionstring"))
  2.         Dim cmd As New MySqlCommand
  3.         Dim sqlquery As String
  4.         sqlquery = "select count(*) from " & tablename & " where URL=" & "\'" & url & "\'" & " ;"
  5.         cmd.CommandType = CommandType.Text
  6.         cmd.CommandText = sqlquery
  7.         cmd.Connection = con
  8.         Dim count As Integer = 0
  9.         con.Open()
  10.         count = cmd.ExecuteScalar()
  11.         con.Close()
  12.         Return count
  13.  
  14.  
both tablename and url are received as strings and applied here.
also...
when i ran the query without the where condition it works!!
any idea as to whats wrong with this?
thanks,
gomzi.
Apr 22 '07 #1
1 11708
gomzi
304 Contributor
hi,
When i try to select the number of rows in my table depending on a where condition i get this error : -

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

my select statement is like this:-

Expand|Select|Wrap|Line Numbers
  1. Dim con As New MySqlConnection(ConfigurationManager.AppSettings("connectionstring"))
  2.         Dim cmd As New MySqlCommand
  3.         Dim sqlquery As String
  4.         sqlquery = "select count(*) from " & tablename & " where URL=" & "\'" & url & "\'" & " ;"
  5.         cmd.CommandType = CommandType.Text
  6.         cmd.CommandText = sqlquery
  7.         cmd.Connection = con
  8.         Dim count As Integer = 0
  9.         con.Open()
  10.         count = cmd.ExecuteScalar()
  11.         con.Close()
  12.         Return count
  13.  
  14.  
both tablename and url are received as strings and applied here.
also...
when i ran the query without the where condition it works!!
any idea as to whats wrong with this?
thanks,
gomzi.
solved it guys...
This should actually be like this.
sqlquery = "select count(*) from " & tablename & " where URL=" & "'" & url & "'" & " ;"

thanks a lot to all those who tried....
Apr 22 '07 #2

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

Similar topics

17
2867
by: matthias_k | last post by:
Hi, I am currently implementing a solver for linear optimization problems using the revised simplex method and I stumbled accross some strange behavior regarding the treatment of the number 0. I am not sure whether this is compiler or language related though. The first problem is, that there are two representations of zero, namely +0 and -0. Does IEEE for floating points allow this? Maybe I didn't activate IEEE floating point numbers?
14
5423
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
6
11081
by: Francois Vanderseypen | last post by:
This nested 'for' gives an out of range error on the second pass of the second loop, though it looks allright. Isn't it wierd? for (int tel1=0;tel1<3;tel1++) { for (int tel2=0;tel2<15;tel2++) { p=tel2; } }
1
1748
by: Jan Killian | last post by:
Hi all, maybe you'll see the trick and could help me. I am passing int by reference and get an exception when using it as an index to passed array. (Yes I know I can workaround with object encapsulation, but wish to understand this). Thanks, Jan using System;
5
3188
by: Gérard Talbot | last post by:
Hello fellow colleagues, Can someone explain to me why, in this page http://www.aplus.co.yu/css/z-pos/index4.php#content , AP1 should not be in front of (overlapping) AP2 ? Recap: RP1 is relatively positioned block, with z-index:11 AP1 is an absolutely positioned block, with z-index:10, nested inside RP1
7
2925
by: Cyberwolf | last post by:
Is there a way to set a primary index to ignore Nulls and if so how would I do it. I have already tried setting it so it is not a required field, but that does not work. It states that the field can not contain null values.
9
4045
by: Daniel Vukadinovic | last post by:
I want to implement an index/counter to my linked list. Why? I wrote a search function which searches the list for elements based on their values (say I add an element and I assign the value 54 and the next element 789 and so on...) now I'd like to write a search function which would search the list for elements based on their index. Say first element is 54 and index 1, second element is 789 and index 2 so when I want to search, I'll do...
6
6242
by: john | last post by:
Last week I posted about making a unique index on multiple fields to prevent importing identical records twice. I still have trouble with the nulls in the index. The only way that I can make it work is to make all the index' fields required fields and set the allow nulls setting to false. But then every field in the index should always have some kind of value, and I have to put a default value like "0" in them or "empty". Is this indeed the...
23
4376
by: Hallvard B Furuseth | last post by:
As far as I can tell, (x & -1) is nonzero if the integer x is negative zero. So for signed types, x == 0 does not guarantee (x & foo) == 0. Is that right? (Not that I expect to ever encounter a non-two's-complement machine. Just wondering.) -- Hallvard
0
9655
marktang
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...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
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...
0
9964
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
7517
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
5398
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.