467,907 Members | 1,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

OleDbData Provider for Access + DataGrid shows '0' instead of '1'

Very strange problem: Executing my query against MS Access database using
OleDbProvider for Access, I am getting the value for first two columns '0'
instead of '1' in DataGrid. But if I connect to SQL Server using
OleDbProvider, it shows me the correct value i.e. 1 wherever it should be.

To debug i write the query to a file. Now copy the query from that file to
Acess SQL View and run. Here it shows the correct value 1 for the first two
columns wherever it should be 1.

I think this is the problem of OleDbData Provider for Access in .NET.

The first two columns are created on the fly i.e. these columns doesn’t
exist in table I just create as a view. But this query is populating the
correct value for the first two columns when I connect to SQL Server, but
connecting to MS Access using OleDb Provider to .NET it populates ‘0’ in
place of ‘1’ for the first two columns. Rest of the things are ok.

QUERY:

" SELECT "+
" (select Quantity from Items_Detail idt "+
" where idt.Barcode = MB.Barcode "+
" AND MB.inv_date='Friday, September 16, 2005'" +
" ) AS \"Qty on: Friday, September 16, 2005\"" +

" ,(select Quantity from Items_Detail idt "+
" where idt.Barcode = MB.Barcode "+
" AND MB.inv_date='Tuesday, September 20, 2005'"+
" ) AS \"Qty on: Tuesday, September 20, 2005\""+

" , idt.Barcode, idt.Place, idt.Description, idt.[Purchase Date],
idt.[Years Used], idt.[Condition], idt.[Actual], idt.[Elevative],
idt.[Depreciation], idt.[Notebook Value], idt.Present, idt.Absent,
idt.[Absence Reason] " +

" FROM Items_Detail idt, "+
" (" +
// /*The purpose of this query is to return the missing Barcodes in either
of two Dates*/
" SELECT Inv_Date, Barcode FROM Inventory inv "+
" WHERE "+
" inv.Barcode IN (select inventory.Barcode from inventory where
inv_date='Friday, September 16, 2005')"+
" AND inv.Barcode NOT IN (select inventory.Barcode from inventory where
inv_date='Tuesday, September 20, 2005')"+
" OR "+
" inv.Barcode IN (select inventory.Barcode from inventory where
inv_date='Tuesday, September 20, 2005')"+
" AND inv.Barcode NOT IN (select inventory.Barcode from inventory where
inv_date='Friday, September 16, 2005')"+
" ) MB " +
///*Missed Barcodes*/
" WHERE idt.Barcode = MB.Barcode "+
" AND (MB.Inv_Date = 'Friday, September 16, 2005' OR MB.Inv_Date = 'Tuesday,
September 20, 2005') ";

Arif.

Nov 21 '05 #1
  • viewed: 1434
Share:
2 Replies
The Format of SQL Server's Date is different as Access! You can try sign #
instead of ' in Access, or use OleDbParameter and OleDbType.Date.
"Arif" <Ar**@discussions.microsoft.com> дϢ:05**********************************@ microsoft.com...
Very strange problem: Executing my query against MS Access database using
OleDbProvider for Access, I am getting the value for first two columns '0'
instead of '1' in DataGrid. But if I connect to SQL Server using
OleDbProvider, it shows me the correct value i.e. 1 wherever it should be.

To debug i write the query to a file. Now copy the query from that file to
Acess SQL View and run. Here it shows the correct value 1 for the first
two
columns wherever it should be 1.

I think this is the problem of OleDbData Provider for Access in .NET.

The first two columns are created on the fly i.e. these columns doesnt
exist in table I just create as a view. But this query is populating the
correct value for the first two columns when I connect to SQL Server, but
connecting to MS Access using OleDb Provider to .NET it populates 0 in
place of 1 for the first two columns. Rest of the things are ok.

QUERY:

" SELECT "+
" (select Quantity from Items_Detail idt "+
" where idt.Barcode = MB.Barcode "+
" AND MB.inv_date='Friday, September 16, 2005'" +
" ) AS \"Qty on: Friday, September 16, 2005\"" +

" ,(select Quantity from Items_Detail idt "+
" where idt.Barcode = MB.Barcode "+
" AND MB.inv_date='Tuesday, September 20, 2005'"+
" ) AS \"Qty on: Tuesday, September 20, 2005\""+

" , idt.Barcode, idt.Place, idt.Description, idt.[Purchase Date],
idt.[Years Used], idt.[Condition], idt.[Actual], idt.[Elevative],
idt.[Depreciation], idt.[Notebook Value], idt.Present, idt.Absent,
idt.[Absence Reason] " +

" FROM Items_Detail idt, "+
" (" +
// /*The purpose of this query is to return the missing Barcodes in either
of two Dates*/
" SELECT Inv_Date, Barcode FROM Inventory inv "+
" WHERE "+
" inv.Barcode IN (select inventory.Barcode from inventory where
inv_date='Friday, September 16, 2005')"+
" AND inv.Barcode NOT IN (select inventory.Barcode from inventory where
inv_date='Tuesday, September 20, 2005')"+
" OR "+
" inv.Barcode IN (select inventory.Barcode from inventory where
inv_date='Tuesday, September 20, 2005')"+
" AND inv.Barcode NOT IN (select inventory.Barcode from inventory where
inv_date='Friday, September 16, 2005')"+
" ) MB " +
///*Missed Barcodes*/
" WHERE idt.Barcode = MB.Barcode "+
" AND (MB.Inv_Date = 'Friday, September 16, 2005' OR MB.Inv_Date =
'Tuesday,
September 20, 2005') ";

Arif.


Nov 23 '05 #2
Thanks Jason,

the type of field is 'Text' not 'Date' for that column. So it must be
treated as a text type field. Another thing is that as I have already
mentioned that to debug i write the query also to a text file. Later i copy
the query and pasted to Access's SQL View. Here it is showing the correct
output. Therefore it is looking to me that it the problem/bug of
OleDbProvider for Access in .NET.

Well I will also try your suggestion and will inform you.

Thanks for your kind support,
Arif.
"Jason W. Sun" wrote:
The Format of SQL Server's Date is different as Access! You can try sign #
instead of ' in Access, or use OleDbParameter and OleDbType.Date.
"Arif" <Ar**@discussions.microsoft.com> дÈëÏûÏ¢ÐÂÎÅ:05*********************** ***********@microsoft.com...
Very strange problem: Executing my query against MS Access database using
OleDbProvider for Access, I am getting the value for first two columns '0'
instead of '1' in DataGrid. But if I connect to SQL Server using
OleDbProvider, it shows me the correct value i.e. 1 wherever it should be.

To debug i write the query to a file. Now copy the query from that file to
Acess SQL View and run. Here it shows the correct value 1 for the first
two
columns wherever it should be 1.

I think this is the problem of OleDbData Provider for Access in .NET.

The first two columns are created on the fly i.e. these columns doesn¡¯t
exist in table I just create as a view. But this query is populating the
correct value for the first two columns when I connect to SQL Server, but
connecting to MS Access using OleDb Provider to .NET it populates ¡®0¡¯ in
place of ¡®1¡¯ for the first two columns. Rest of the things are ok.

QUERY:

" SELECT "+
" (select Quantity from Items_Detail idt "+
" where idt.Barcode = MB.Barcode "+
" AND MB.inv_date='Friday, September 16, 2005'" +
" ) AS \"Qty on: Friday, September 16, 2005\"" +

" ,(select Quantity from Items_Detail idt "+
" where idt.Barcode = MB.Barcode "+
" AND MB.inv_date='Tuesday, September 20, 2005'"+
" ) AS \"Qty on: Tuesday, September 20, 2005\""+

" , idt.Barcode, idt.Place, idt.Description, idt.[Purchase Date],
idt.[Years Used], idt.[Condition], idt.[Actual], idt.[Elevative],
idt.[Depreciation], idt.[Notebook Value], idt.Present, idt.Absent,
idt.[Absence Reason] " +

" FROM Items_Detail idt, "+
" (" +
// /*The purpose of this query is to return the missing Barcodes in either
of two Dates*/
" SELECT Inv_Date, Barcode FROM Inventory inv "+
" WHERE "+
" inv.Barcode IN (select inventory.Barcode from inventory where
inv_date='Friday, September 16, 2005')"+
" AND inv.Barcode NOT IN (select inventory.Barcode from inventory where
inv_date='Tuesday, September 20, 2005')"+
" OR "+
" inv.Barcode IN (select inventory.Barcode from inventory where
inv_date='Tuesday, September 20, 2005')"+
" AND inv.Barcode NOT IN (select inventory.Barcode from inventory where
inv_date='Friday, September 16, 2005')"+
" ) MB " +
///*Missed Barcodes*/
" WHERE idt.Barcode = MB.Barcode "+
" AND (MB.Inv_Date = 'Friday, September 16, 2005' OR MB.Inv_Date =
'Tuesday,
September 20, 2005') ";

Arif.


Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by StepUP | last post: by
3 posts views Thread by Jim Heavey | last post: by
10 posts views Thread by Jennyfer J Barco | last post: by
5 posts views Thread by HS1 | last post: by
reply views Thread by Elton Wang | last post: by
5 posts views Thread by tshad | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.