473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Cannot select data by range.

Dear All,
I have an application written by VB.Net with connect to a
Microsoft Access database.
One of the forms is to select data using oleAdapter and fill it
into a dataset. In the oleAdapter, i have two parameter : FromNation
and ToNation.
The select statement as follow :

SELECT SID, EmpyCode, EmpyName, LastDayWorked, NationCode,
LocCode, DeptCode, Status, RepStatus, ReqRemarks
FROM PRCR_EmpyPerMas
WHERE (NationCode >= FromNation) AND (NationCode <= ToNation)
ORDER BY EmpyName, EmpyCode

Then before i fill data into dataset, i assign the value to
parameters, if user not enter any data then system will default
FromNation = ' ' and ToNation = 'ZZZZZZ'. This works fine, it returns
all records.

However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'.

Any solution?

Thanks a lot.

Regards,

Lee Han Lim
Nov 20 '05 #1
5 1724
* hl***@lintramax.com (Han Lim) scripsit:
One of the forms is to select data using oleAdapter and fill it
into a dataset. In the oleAdapter, i have two parameter : FromNation
and ToNation.
The select statement as follow :

SELECT SID, EmpyCode, EmpyName, LastDayWorked, NationCode,
LocCode, DeptCode, Status, RepStatus, ReqRemarks
FROM PRCR_EmpyPerMas
WHERE (NationCode >= FromNation) AND (NationCode <= ToNation)
ORDER BY EmpyName, EmpyCode


For data(base) related questions, give this group a try:

<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<URL:http://msdn.microsoft.com/newsgroups/?dg=microsoft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Han Lim,
However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'. Does you table contain IND specifically, or does it contain "INDIA"?

As INDIA is not less or equal to IND. If it contains INDIA, you may want to
consider using Like instead of a range.

Something like:

Where NationCode Like ToNation

Where ToNation contains "IND%" (verify the '%' on Access, it may be '*'.

In your original case I would consider using Between, something like:

Where NationCode Between FromNation And ToNation

The reason you should use Like instead of appending "ZZZZ" to the end of IND
is it will handle international characters correctly.

As Herfried suggested, you may want to ask this question "down the hall" in
either the adonet newsgroup he gave or one of the access specific
newsgroups.

Hope this helps
Jay

"Han Lim" <hl***@lintramax.com> wrote in message
news:73*************************@posting.google.co m... Dear All,
I have an application written by VB.Net with connect to a
Microsoft Access database.
One of the forms is to select data using oleAdapter and fill it
into a dataset. In the oleAdapter, i have two parameter : FromNation
and ToNation.
The select statement as follow :

SELECT SID, EmpyCode, EmpyName, LastDayWorked, NationCode,
LocCode, DeptCode, Status, RepStatus, ReqRemarks
FROM PRCR_EmpyPerMas
WHERE (NationCode >= FromNation) AND (NationCode <= ToNation)
ORDER BY EmpyName, EmpyCode

Then before i fill data into dataset, i assign the value to
parameters, if user not enter any data then system will default
FromNation = ' ' and ToNation = 'ZZZZZZ'. This works fine, it returns
all records.

However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'.

Any solution?

Thanks a lot.

Regards,

Lee Han Lim

Nov 20 '05 #3
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<#5**************@TK2MSFTNGP12.phx.gbl>...
Han Lim,
However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'.

Does you table contain IND specifically, or does it contain "INDIA"?

As INDIA is not less or equal to IND. If it contains INDIA, you may want to
consider using Like instead of a range.

Something like:

Where NationCode Like ToNation

Where ToNation contains "IND%" (verify the '%' on Access, it may be '*'.

In your original case I would consider using Between, something like:

Where NationCode Between FromNation And ToNation

The reason you should use Like instead of appending "ZZZZ" to the end of IND
is it will handle international characters correctly.

As Herfried suggested, you may want to ask this question "down the hall" in
either the adonet newsgroup he gave or one of the access specific
newsgroups.

Hope this helps
Jay

"Han Lim" <hl***@lintramax.com> wrote in message
news:73*************************@posting.google.co m...
Dear All,
I have an application written by VB.Net with connect to a
Microsoft Access database.
One of the forms is to select data using oleAdapter and fill it
into a dataset. In the oleAdapter, i have two parameter : FromNation
and ToNation.
The select statement as follow :

SELECT SID, EmpyCode, EmpyName, LastDayWorked, NationCode,
LocCode, DeptCode, Status, RepStatus, ReqRemarks
FROM PRCR_EmpyPerMas
WHERE (NationCode >= FromNation) AND (NationCode <= ToNation)
ORDER BY EmpyName, EmpyCode

Then before i fill data into dataset, i assign the value to
parameters, if user not enter any data then system will default
FromNation = ' ' and ToNation = 'ZZZZZZ'. This works fine, it returns
all records.

However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'.

Any solution?

Thanks a lot.

Regards,

Lee Han Lim


First of all, thanks for your reply. Sorry for posting the question at
the wrong group.

Yes my table contains IND specifically, i did try to use between
statement, it did work.

I found that, if i format the lsFromNation = ' IND' and to
lsToNation = ' IND' then everything works. My column
datatype is text, length = 15. Is it a must to format my parameter to
15 chars? I know if I declare varchar(15) in MS SQL, i don't have to
format parameter to equel length, but i'm not sure about ACCESS.

Regards,

Lee Han Lim
Nov 20 '05 #4
Han,
I found that, if i format the lsFromNation = ' IND' and to
lsToNation = ' IND' then everything works. My column
datatype is text, length = 15. Is it a must to format my parameter to
15 chars? I know if I declare varchar(15) in MS SQL, i don't have to
format parameter to equel length, but i'm not sure about ACCESS.
As you found, 'IND' is not ' IND' , if it works with the spaces,
then you need the spaces.

Personally I would trim the spaces from the values going into the Access
database, unless there is a specific need to have them there.

Hope this helps
Jay

"Han Lim" <hl***@lintramax.com> wrote in message
news:73**************************@posting.google.c om... "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message

news:<#5**************@TK2MSFTNGP12.phx.gbl>...
Han Lim,
However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'.

Does you table contain IND specifically, or does it contain "INDIA"?

As INDIA is not less or equal to IND. If it contains INDIA, you may want to consider using Like instead of a range.

Something like:

Where NationCode Like ToNation

Where ToNation contains "IND%" (verify the '%' on Access, it may be '*'.

In your original case I would consider using Between, something like:

Where NationCode Between FromNation And ToNation

The reason you should use Like instead of appending "ZZZZ" to the end of IND is it will handle international characters correctly.

As Herfried suggested, you may want to ask this question "down the hall" in either the adonet newsgroup he gave or one of the access specific
newsgroups.

Hope this helps
Jay

"Han Lim" <hl***@lintramax.com> wrote in message
news:73*************************@posting.google.co m...
Dear All,
I have an application written by VB.Net with connect to a
Microsoft Access database.
One of the forms is to select data using oleAdapter and fill it
into a dataset. In the oleAdapter, i have two parameter : FromNation
and ToNation.
The select statement as follow :

SELECT SID, EmpyCode, EmpyName, LastDayWorked, NationCode,
LocCode, DeptCode, Status, RepStatus, ReqRemarks
FROM PRCR_EmpyPerMas
WHERE (NationCode >= FromNation) AND (NationCode <= ToNation)
ORDER BY EmpyName, EmpyCode

Then before i fill data into dataset, i assign the value to
parameters, if user not enter any data then system will default
FromNation = ' ' and ToNation = 'ZZZZZZ'. This works fine, it returns
all records.

However, when i enter 'IND' for FromNation and 'IND' for ToNation,
it doesn't return any record. I know my table has record with 'IND'.

Any solution?

Thanks a lot.

Regards,

Lee Han Lim


First of all, thanks for your reply. Sorry for posting the question at
the wrong group.

Yes my table contains IND specifically, i did try to use between
statement, it did work.

I found that, if i format the lsFromNation = ' IND' and to
lsToNation = ' IND' then everything works. My column
datatype is text, length = 15. Is it a must to format my parameter to
15 chars? I know if I declare varchar(15) in MS SQL, i don't have to
format parameter to equel length, but i'm not sure about ACCESS.

Regards,

Lee Han Lim

Nov 20 '05 #5
Jay, thanks a lot for your suggestion. I use "Trim", and i works.

Regards,

Lee Han Lim.

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<#N**************@tk2msftngp13.phx.gbl>...
Han,
I found that, if i format the lsFromNation = ' IND' and to
lsToNation = ' IND' then everything works. My column
datatype is text, length = 15. Is it a must to format my parameter to
15 chars? I know if I declare varchar(15) in MS SQL, i don't have to
format parameter to equel length, but i'm not sure about ACCESS.


As you found, 'IND' is not ' IND' , if it works with the spaces,
then you need the spaces.

Personally I would trim the spaces from the values going into the Access
database, unless there is a specific need to have them there.

Hope this helps
Jay

"Han Lim" <hl***@lintramax.com> wrote in message
news:73**************************@posting.google.c om...
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message

news:<#5**************@TK2MSFTNGP12.phx.gbl>...
Han Lim,
> However, when i enter 'IND' for FromNation and 'IND' for ToNation,
> it doesn't return any record. I know my table has record with 'IND'.
Does you table contain IND specifically, or does it contain "INDIA"?

As INDIA is not less or equal to IND. If it contains INDIA, you may want to consider using Like instead of a range.

Something like:

Where NationCode Like ToNation

Where ToNation contains "IND%" (verify the '%' on Access, it may be '*'.

In your original case I would consider using Between, something like:

Where NationCode Between FromNation And ToNation

The reason you should use Like instead of appending "ZZZZ" to the end of IND is it will handle international characters correctly.

As Herfried suggested, you may want to ask this question "down the hall" in either the adonet newsgroup he gave or one of the access specific
newsgroups.

Hope this helps
Jay

"Han Lim" <hl***@lintramax.com> wrote in message
news:73*************************@posting.google.co m...
> Dear All,
> I have an application written by VB.Net with connect to a
> Microsoft Access database.
> One of the forms is to select data using oleAdapter and fill it
> into a dataset. In the oleAdapter, i have two parameter : FromNation
> and ToNation.
> The select statement as follow :
>
> SELECT SID, EmpyCode, EmpyName, LastDayWorked, NationCode,
> LocCode, DeptCode, Status, RepStatus, ReqRemarks
> FROM PRCR_EmpyPerMas
> WHERE (NationCode >= FromNation) AND (NationCode <= ToNation)
> ORDER BY EmpyName, EmpyCode
>
> Then before i fill data into dataset, i assign the value to
> parameters, if user not enter any data then system will default
> FromNation = ' ' and ToNation = 'ZZZZZZ'. This works fine, it returns
> all records.
>
> However, when i enter 'IND' for FromNation and 'IND' for ToNation,
> it doesn't return any record. I know my table has record with 'IND'.
>
> Any solution?
>
> Thanks a lot.
>
> Regards,
>
> Lee Han Lim


First of all, thanks for your reply. Sorry for posting the question at
the wrong group.

Yes my table contains IND specifically, i did try to use between
statement, it did work.

I found that, if i format the lsFromNation = ' IND' and to
lsToNation = ' IND' then everything works. My column
datatype is text, length = 15. Is it a must to format my parameter to
15 chars? I know if I declare varchar(15) in MS SQL, i don't have to
format parameter to equel length, but i'm not sure about ACCESS.

Regards,

Lee Han Lim

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
0
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
3
by: Agnes | last post by:
Dim dsExcelExport As New System.Data.DataSet Dim daExcelExport As New System.Data.SqlClient.SqlDataAdapter Dim Excel As New Excel.Application Dim strExcelFile As String Dim strFileName As...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
2
by: chrisale | last post by:
Hi All, I've been racking my brain trying to figure out some sort of Sub-Select mySQL statement that will create a result with multiple rows of averaged values over a years time. What I have...
2
by: bbasberg | last post by:
I have been working hard to clean up my code but I am still wondering why all incoming records go to the "AddNew" part of the IF statement and never to the Edit alternative. I believe that it must be...
2
by: cendter | last post by:
Hi there, I am utterly confused - I have a form that starts an instance from excel and let's the user select a range. I then want to take this range as an array of doubles. I ran into trouble...
2
by: shannonwhitty | last post by:
I am able to extract dates in the correct format i.e. SELECT CONVERT(VARCHAR(8), GETDATE(), 3) =dd/mm/yy My issue is that my users are selecting a date in this format and I need to select...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.