Welcome to the Monastery PerlMonks

### Re: accessing field names in Access table?

by digger (Friar)
 on Sep 18, 2003 at 14:12 UTC ( #292393=note: print w/replies, xml ) Need Help??

in reply to accessing field names in Access table?

I am just getting into a project that requires me to use an Access db for the backend. I settled on using Win32::ODBC . There is an excellent tutorial here on getting started with the module, and it is very easy.

The only issue I struggled with is the ODBC connection string. If you can create a system DSN, you don't need to worry. But if not, you will have to write your own connection string.

The format is
my $connstring = 'Driver={Microsoft Access Driver (*.mdb)}; Dbq=d:path +\\to\\your\\db.mdb; Uid=user; Pwd=password' [download] After you have your connection string, get the field names with the following code: my$db = new Win32::ODBC($connstring);$db->Sql('SELECT * FROM table WHERE field = param')
\$db->FieldNames();
[download]
This will give you an array containing all of the field names in the data set retrieved by the SQL statement.

One last gotcha - the method calls are case sensitive in this module, so make sure your calls have the same capitalization as the docs.

Of course, all of this assumes you are working on a win32 platform. If you are on *nix platform, ignore everything I said. There is currently no way to use an Access db natively on *nix. There are the mdbtools mentioned above, and some software that will create a remote connection to win32 box to work with an Access db, but nothing native...yet.

Good Luck and Happy Coding,
digger

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://292393]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-05-24 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Do you prefer to work remotely?

Results (82 votes). Check out past polls.

Notices?
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.27315065264701843, "perplexity": 3474.966739318578}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-21/segments/1652662562410.53/warc/CC-MAIN-20220524014636-20220524044636-00619.warc.gz"}