-2

Alright i have a table which contains 2 bigint column.

Example

val1 3213 12312
val2 13232 32322
.
.
.

select val from table where 3232 between col1 and col2

I need to use between operator to select single row data.

Now i tried dataview but it failed. Dataview is not supporting between operator.

like this

dwIpAddress.RowFilter = string.Format("{0} between CodeVal_1 and CodeVal_2", irParameter);

So which approach i can use ?

There are like 200000 data records.

Tried this and it is super slow

    dwIpAddress.RowFilter = string.Format("CodeVal_1>= {0} and CodeVal_2<={0}", irParameter);

C# 4.0

Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342

1 Answers1

1

have you tried

    dwIpAddress.RowFilter = string.Format("CodeVal_1 <= {0} and {0} <= CodeVal_2", irParameter);

Also, since you mentioned you are using C# 4.0, there is the Entity Framework, which you could use instead of DataView. Something you may want to look into.

Also, if your DataView contains all records from your database table, then you may want to adjust your query so that it only gets the rows from the database that it needs, as opposed to returning all rows and then filtering in C# (if that's what you are doing)

CodeMonkey
  • 629
  • 7
  • 16
  • have you tried running the same sql query directly against the database? And if so, is that also slow? Do you have any indexes on your database? – CodeMonkey Dec 23 '12 at 01:45
  • Yes querying database is also slow even though i have index. i have to query over 500000 times. I need to somehow come with an index scheme that can be used at application ram memory. Like hashtable or dictionary. – Furkan Gözükara Dec 23 '12 at 01:46
  • What do the indexes look like on that table.. perhaps the fields you are trying to get ranges for in regards to your between statement are not part of an index.. can you show list or explain what the indexes are ..? – MethodMan Dec 23 '12 at 02:04
  • What can be index ? of course combination of that 2 value is primary key. so it is the fastest index. – Furkan Gözükara Dec 23 '12 at 03:09