Perl-Sensitive Sunglasses PerlMonks

### comment on

 Need Help??
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
Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Are you posting in the right place? Check out Where do I post X? to know for sure.
• Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
• Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
• Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
 Username: Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-05-20 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Do you prefer to work remotely?

Results (75 votes). Check out past polls.

Notices?