473,386 Members | 1,679 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,386 software developers and data experts.

Access Query returning 0 records in VB.NET 2003 in Vista

1
We have an application developed in VS 203 [VB.NET]
We aretesting the app in WindowsVista
The problem we are facing is as follows:
The app uses an Access database. When trying to execute a select statement, the application returns 0 records, though when the same query is runin Access it returns all the valid records. Please note that we face this ssue only when the app is run in Vista

The details of the codes are as follows:
Dim daGetData As OleDb.OleDbDataAdapter
dim m_Connection As OleDbConnection
dim m_Command As OleDbCommand
dim m_strConnection as string
Dim dtGetData As New DataTable

m_strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="mydb.mdb;Jet OLEDB:Database Password=abcd"

pstrSql = "SELECT FG.GroupID, FG.GroupName, iif(isnull(FS.FSID),0,FS.FSID), iif (isnull(FS.name),'',FS.name), iif( iif(isnull(FS.NP),0,FS.NP) = 0, iif(isnull(FS.TN),'',FS.TN) + "-NEW", FS.TN), FG.enabled, iif(isnull(FS.HV),"N",FS.HV) FROM FG LEFT JOIN FS ON FG.FGID = FS.FGID WHERE FG.FGID >= 100 And FG.FGID < 199 and FS.FS_Status = 'Y' and FS.FSID not in (0) and now() >= RDate and now() <= EDate ORDER BY FG.SortOrder desc, FG.FGID DESC , iif(FS.NP=0,"N","V") desc, FS.Priority, FS.FileSetId "

Try
m_Connection = New OleDb.OleDbConnection(m_strConnection)
m_Connection.Open()
m_Command = New OleDbCommand(p_strSql, m_Connection)
daGetData = New OleDbDataAdapter(m_Command)
daGetData.Fill(dtGetData)

m_Connection.Close()
Return dtGetData
Catch ex As Exception
Throw ex
Finally
daGetData = Nothing
m_Command = Nothing
If Not m_Connection Is Nothing Then m_Connection.Close()
m_Connection = Nothing
End Try

When the above Select statement is executed in Access it correctly returns the records but in the above code, it reurns 0 records. No error!!!

Thank you in advance for any suggestion that you might give.

Narayanan Ramanathan
Aug 3 '07 #1
1 1627
shweta123
692 Expert 512MB
Hi,

You can try giving other way instead of using OledbCommand

daGetData = New OleDbDataAdapter(sqlquery,connection)
daGetData.Fill(dtGetData)





We have an application developed in VS 203 [VB.NET]
We aretesting the app in WindowsVista
The problem we are facing is as follows:
The app uses an Access database. When trying to execute a select statement, the application returns 0 records, though when the same query is runin Access it returns all the valid records. Please note that we face this ssue only when the app is run in Vista

The details of the codes are as follows:
Dim daGetData As OleDb.OleDbDataAdapter
dim m_Connection As OleDbConnection
dim m_Command As OleDbCommand
dim m_strConnection as string
Dim dtGetData As New DataTable

m_strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="mydb.mdb;Jet OLEDB:Database Password=abcd"

pstrSql = "SELECT FG.GroupID, FG.GroupName, iif(isnull(FS.FSID),0,FS.FSID), iif (isnull(FS.name),'',FS.name), iif( iif(isnull(FS.NP),0,FS.NP) = 0, iif(isnull(FS.TN),'',FS.TN) + "-NEW", FS.TN), FG.enabled, iif(isnull(FS.HV),"N",FS.HV) FROM FG LEFT JOIN FS ON FG.FGID = FS.FGID WHERE FG.FGID >= 100 And FG.FGID < 199 and FS.FS_Status = 'Y' and FS.FSID not in (0) and now() >= RDate and now() <= EDate ORDER BY FG.SortOrder desc, FG.FGID DESC , iif(FS.NP=0,"N","V") desc, FS.Priority, FS.FileSetId "

Try
m_Connection = New OleDb.OleDbConnection(m_strConnection)
m_Connection.Open()
m_Command = New OleDbCommand(p_strSql, m_Connection)
daGetData = New OleDbDataAdapter(m_Command)
daGetData.Fill(dtGetData)

m_Connection.Close()
Return dtGetData
Catch ex As Exception
Throw ex
Finally
daGetData = Nothing
m_Command = Nothing
If Not m_Connection Is Nothing Then m_Connection.Close()
m_Connection = Nothing
End Try

When the above Select statement is executed in Access it correctly returns the records but in the above code, it reurns 0 records. No error!!!

Thank you in advance for any suggestion that you might give.

Narayanan Ramanathan
Aug 3 '07 #2

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

Similar topics

2
by: Jennifer | last post by:
I have a query with 5 possible criteria via a form. If criteria is not entered, I use the like Nz() function on the backend query to use an "*" for criteria fields left blank. The query is not...
3
by: etwebbox | last post by:
Hoping someone has some ideas on how to solve this issue: I have a macro in excel which runs a query against an Access DB (it actually calls a query inside of Access). The query is not bringing...
33
by: Steve | last post by:
One of our clients recently upgraded their Office version to 2003. When they tried to run our program (written in Access 2000), they ended up with the wrong data. My coworker and I have tested this...
6
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on...
38
by: kavsak | last post by:
Hi. Not sure that this is the right place to ask but here goes. I have an application based on access97 and VB6 which I need to upgrade. It has to handle up to 20 concurrent users on a Win2k...
13
yolenman
by: yolenman | last post by:
Hello - This is my first posting to this group, so please bear with me. Also note, that while I'm intelligent, databases are not in my field of knowledge. I'm working with a small limousine...
8
by: elias.farah | last post by:
Hello Everyone, I'm having some very weird behavior on a couple of Access forms. (Not all forms, just some of them). The forms have been working for years, under Access XP/2003 etc, and last...
4
by: PabsBath | last post by:
Hello, help please. I have been pulling my hair out for a few weeks now and been looking on the web for answers but not managed to find anything!! I'm currently operating a small (2mb - approx...
6
by: jsacrey | last post by:
Hello everybody, I've got a bit of a situation that I could use some guidance with if possible. I work for an auditing firm where my users audit electronic shipping data for customers to see if...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.