473,386 Members | 1,693 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.

Reading from ms Access

I am new to using perl and am trying to read data from an ms access database.
I have opened the database and can extract data from a table with limited success.
What I have done so far is open the database using
use Win32::ODBC;
etc

Then I have the following code:
Expand|Select|Wrap|Line Numbers
  1. #while ($db->FetchRow())  { 
  2.   while ($i<10) {
  3.   $db->FetchRow() ;
  4.     my %Data = $db->DataHash();
  5.     print $i," ",$Data{Au_plot},"," ;
  6.     print $Data{Cu},"," ;
  7.     print $Data{Zn},"," ;
  8.     print $Data{Pb};
  9.   $i++;
  10.   print "\n";
  11. }
  12.  
This works ok as the first 10 rows are extracted from the table I have selected.
But when I use
Expand|Select|Wrap|Line Numbers
  1. while ($db->FetchRow())  { 
  2.  
  3. instead of
  4. while ($i<10) {
  5.  
the first record extracted is number 2 in the table and from then on only every second record is extracted form the table.

Could someone tell me what is going on please?
Thanks
Chris
Dec 11 '08 #1
1 1852
numberwhun
3,509 Expert Mod 2GB
@new2perl
First, please use code tags around any code you provide in the forums. They are required and need to be added if you forget them.

As far as your questions goes, I don't use MS Access. I like to stick to MySQL myself, but in Perl, when you access a database, you typically use the DBI module in conjunction with a DBD (database driver module). For instance, you always "use DBI", but if I am using MySQL, I would also include "use DBD::mysql" as well so that DBI knew how to interact with my database of choice.

In your case, its MS Access and unfortunately I don't think there is specifically a driver for it, but I know that I have read about people using DBD::ODBC for the interaction. You could give it a try and see if it works for you. I know MS Access is mentioned on the page.

In addition, you may want to search Google as I am sure they have a plethora of information on the topic of using Perl with MS Access.

Regards,

Jeff
Dec 11 '08 #2

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

Similar topics

24
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
3
by: [Yosi] | last post by:
I have some unreasonable issue while reading access component from other thread. I have a Form class which includes TreeView, this tree view includes some TreeNodes , lets say 2 . In my Form...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
14
by: Zahid | last post by:
Hi, What is a VDT file? How do I read a VDT file into my application? I know how to read text files etc but not VDT files. Im preparing in advance a prototype that read VDT files and does...
1
by: Jens | last post by:
Hello, i am just trying to get familiar with the Reflection-Api. I want to access a protected property of my class using the getValue-method of ReflectionProperty-Class. When i execute the code...
2
by: Paul M | last post by:
Hello, is there any way of reading Microsoft Access Macros via VBA code? Or better still through VB .net code? By reading I mean being able to read what the actions are plus any parameters &...
3
by: Budd | last post by:
Hi all, This is my first time here so treat me gently.....I have dabbled with Access now for a number of years and find I can create what I require...the thing I have always struggled with though...
3
by: darren via AccessMonster.com | last post by:
Hi I'm based in the UK and I've drifted into Access from building a simple db for myself, to then being asked to build a simple db for someone else, to now spending time building increasingly...
19
by: Hapa | last post by:
Does only reading (never writing) of a variable need thread synchronisation? Thanks for help? PS. Anybody knows a Visual C++ news group?
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.