The only thing that sub is doing is opening a connection, whereas your title seems to indicate you're doing an update -- someplace else in your code, maybe?
The exact equivalent to your sub, using DBI and DBD::ADO is this:
use DBI;
sub open_conn
{
# join isn't stricly necessary,
# it just improves readability.
my $strConnect = join ';',
'Provider=SQLOLEDB.1',
'Data Source=iblons3506\oi_c1_prd4',
'Initial Catalog=OMDPortal',
'User ID=OMDPortal_General',
'Password=ObFuScAtEd';
my $dbh = DBI->connect("dbi:ADO:$strConnect", '', '')
or die "Can't connect: $DBI::errstr\n";
}
That snippet shares some of the problems in the VB code: it doesn't do anything intelligent if the connection fails (just dies), and it uses embedded passwords. But this one does return a value, the database handle (presumably in your VB program
oConn is a global?)
But the point is, you can see how I mechanically translated your code. Depending on how dependent on ADO your code is, you may want to change the code more to take advantage of Perl's capabilities, or just translate part by part, using Win32::OLE or some such.
-
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 How to display code and escape characters
are good places to start.