Please help. I am trying to finish this code to access a database and all I am getting is an ODBC error saying that there is an invalid cursor at line 50. Here's the listing.
#!usr/perl/bin use CGI; use DBI; $q = new CGI; @data; $department_type_local = "1"; my ($dbh) = DBI->connect("DBI:ODBC:messagestore") or die "Couldn't con +nect to database"; my ($query) = $dbh->prepare('SELECT message_table.message_id, message_ +table.message_date, message_table.message_time,message_table.message_ +sender_name,message_table.message_to_name, message_table.department_i +d FROM department_table INNER JOIN message_table ON department_table. +department_id = message_table.department_id WHERE message_table.department_id = ?'); $query->execute($department_type) or die "Couldn't execute statement"; if ($query->rows == 0){ my ($errormessage) = "No Records Found...Please Select Again"; print "Content-type:text/html\n\n"; ... } else { while (@data = $dbh->selectrow_array($query)){ my ($message_id) = $data[1]; my ($message_date) = $data[2]; my ($message_time) = $data[3]; my ($message_sender_name) = $data[4]; my ($message_to_name) = $data[5]; my ($department_id) = $data[6]; print "$message_id $message_date $message_time $message_sender_n +ame $message_to_name\n"; } print "Content-type:text/html\n\n" ... } $query->finish; $dbh->disconnect;
If you can help, I would be very grateful. Cheers Grax.

In reply to More DBI Problems!!! by grax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.