![]() |
The Win32::ODBC Module![]() ![]() ![]() ![]() ![]()
Win32::ODBC, written by Dave Roth, is module extension to Win32 Perl. Dave Roth has created a wonderful set of methods that make connecting to you( win32 database a portable and simple task. Using win32::ODBC methods, you can connect to your database, create tables, insert data, and retrieve data. Here you will learn about the more frequently used methods of win32::ODBC. The Close Method The close method disconnects your program from the database engine. You should always close your database connection. Do not depend on Perl to close the open file handle. Your database engine is likely to have opened working files, which may not be properly closed when your program exits. The close method requries an object reference as its first and only parameter $myDb >close(); The Data Method The data method accesses a data structure internal to the win32::ODBC module to retrieve the column values of individual row. The Data method has meaning only after your program has retrieved data from your database through a Sol statement. The Data method retrieves the columns from the current row, use the FetchRow method to get the row of data. You can retrieve all the columns of row in unspecified order like this: lvalue = $myDb >Data(); You can retrieve an ordered list of the columns in a row by specifying which columns you wish to retrieve, as in this example: lvalue = $myDb >Data(lastName,firstName, Address), The data will be returned in the same order as requested. If the Ivalue is a scalar, the Data method returns the column values in one concatenated string. If the Ivalue is a list, the data is returned in list context, where each item in the list is a column va lue. The DataHash Method
The DataHash method accesses an internal data structure to retrieve the column values of an individual row. The DataHash method only has meaning after your program has retrieved data from your database through a SQL statement. The DataHash method retrieves the columns from the current row, use FetchRow method to get the next row of data.
The New Method The new method is the win32::ODBC class constructor. The new method takes one parameter, a valid DSN, and returns an ODBC object reference. my $myDb = win32::ODBC >new("Auto Ads"); The ODBC object reference is then used to communicate further ODBC commands to the connected database. RowCount Method
If the new method fails, it returns undef. Always check the result returned by the new method. If an invalid result is returned your best solution is to print or log the error message and exit your program:
Sometimes, you just want to count the number of rows in a table. The quickes method to accomplish this task is the RowCount method. The RowCount method returns the number of rows that were traversed by the last SQL command
$myDb-->sql($SQL) Sql Method The Sql method is the real workhorse of the win32::ODBC class, but it really isn't an ODBC command. The Sql method makes a call to ODBCExecute, which passes the SQL statement to the database. The Sql method returns undef on success. This means your error checking syntax is reversed. Instead of checking for a positive response to indicate success, you check for a positive response to indicate failure. In the example above, the error handling code will be called when anything other than undef is returned by the Sql method.
|
|
CGI
Advantages of CGI
How CGI Works
Compiled Versus Interpreted
Input to CGI
CGI Introduction Program
HTML Forms
Accepting Input from the Browser
CGI Environment Variables
Get Versus Post Method
Get Method
Post Method
Sample <FORM> Based CGI Program
Complete Example for <FORM>
Output from CGI
Header and Body:Anatomy of Server Response
HTTP Headers
Carriage Returns and Newlines
Formatting Output CGI Common MIME TypesLocation Header Useful HTTP Stautus Codes Other Headers Dynamic Pages Sending Images Displaying the Current Date Feedback Form Program Server Side Includes Server Side Include Environment Variables Displaying the Date with Date Counter Example of SSI Counting the Number of Accesses Better Approach Towards CGI Program Client Versus Server Accessing a HTML Document Submitting a Form Accessing a CGI Program Databases ODBC Creating a DSN Win32::ODBC Module Creating a Table Inserting Data into a Table Deleting Data from a Table
Updating Data in a Table
Selecting Data from a Table Operating Systems Security Securing Your Web Server Writing Secure CGI ProgramWeb DesignDomain Names Home
FAQ
My Account
IP Address
SSL Certificates DNSWeb Hosting Web Server Cheap Web Design Dedicated web hosting Managed web hostingE Commerce Principles of E-Commerce E-Banking Electronic Payment System E-Security Credit Cards Smart Cards
The Mailbox POP Server SMTP Server IMAP Protocol |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |