Results 1 to 7 of 7

Thread: PerlScript for ASP

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140

    PerlScript for ASP

    Okay, I am getting sick of VBScript, and want to use PerlScript.

    Does anyone else do this? Is it good, bad, ugly? How can I rewrite the following VBScript function with PerlScript?

    Code:
    <%
      Function OpenDB(adodbConn, strDBQFileName)
    
        Set adodbConn = Server.CreateObject("ADODB.Connection")
        adodbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBQFileName
    
      End Function
    %>
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Did you download and install ActivePerl from www.activestate.com? This is from their documentation:
    Code:
    <%
    # Create an instance of the ADO Connection object
    #
    $Conn = $Server->CreateObject("ADODB.Connection");
    
    # Open a system DSN
    #
    $Conn->Open( "ADOSamples" );
    
    # Execute an SQL Query
    #
    $RS = $Conn->Execute( "SELECT * FROM Orders" );
    
    # Read a property to get the number of columns
    # present in the Recordset returned from the
    # query.
    #
    $count = $RS->Fields->{Count};
    
    # Print out the names of each column
    #
    for ( $i = 0; $i < $count; $i++ ) {
    $Response->Write( $RS->Fields($i)->Name );
    $Response->Write("<BR>");
    };
    
    # Loop the Recordset until there are no more records
    #
    while ( ! $RS->{EOF} ) {
    for ( $i = 0; $i < $count; $i++ ) {
    $Response->Write(" ");
    $Response->Write($RS->Fields($i)->{Value});
    $Response->Write("<BR>");
    };
    
    # Move to the next record
    #
    $RS->MoveNext();
    };
    
    # Close the Recordset
    #
    $RS->Close();
    $Conn->Close();
    %>
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Whoohooo. No, I haven't downloaded ActivePerl, yet. I'm busy poking around ActiveState's web site. I was hoping to find documentation online. And I've found stuff about the ASP COM interface ($Session, $Request, et al). What you provided helps, but...

    It uses a system DSN. We were having problems with that in VBScript, which is why we call the Jet driver instead of the DSN. I guess I could go back to the DSN and see if we have the same problems when using PerlScript.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Ohwait... I just found the doco you provided, and I found this...

    There are a number of things you can do to get the native provider set up. When you have it set up, you simply replace the name of the system DSN with the string that has been produced in order to connect to the data store using the native OLE DB provider. First, try to create an Universal Data Link file by doing the following:

    1) Create a file named connectionstring.udl
    2) Right-click on it
    3) Choose Properties
    4) Choose the OLE DB Provider to use
    5) Define what source to connect to and possibly a username and password
    6) Click "Test Connection"
    7) Open the file in "Notepad"
    8) Highlight the connectionstring and press CTRL+C to copy it into memory
    9) Paste it into your ADO application by pressing CTRL+V
    If you are not lucky enough to have .udl, locate a friend who has it or dig around for the connectionstrings. It is more than feasible that there are texts on it available on the Internet, too. To give an example, this is what a typical connectionstring looks like for an Access database:
    Code:
    Provider=Microsoft.Jet.OLEDB.4.0;
    User ID=Somebody;
    Data Source=c:\\access.mdb;
    Persist Security Info=False
    I'll have to hunt for that since that is what we are doing inline in the VBScript.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Okay, so if I understand this correctly....

    Code:
    $adodbConn = $Server->CreateObject("ADODB.Connection");
    $adodbConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$strDBQFileName");
    Ohwait, I found this...

    Code:
    $adodbConn->Open(<<EOF);
    Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source=$strDBQFileName
    EOF
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  6. #6
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    I just copied and pasted from the documentation. I didn't see the DSN until after.

    It shouldn't make a difference whether you use DSN name or a connection string (syntax wise). ADO will intrepret it, not Perlscript.

    Code:
    $Conn->Open( "ADOSamples" );
    
    $Conn->Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Databases\whatever.mdb;" );
    OLEDB is the way to go, though.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Cool, cool. Yeah, I'm finding more doco, too. This is great. That was the only question I had before attempting to do this in PerlScript. I'll go ahead and download ActivePerl.

    Now I just have to remember how to do all those wonderful things with anonymous variables and pointers. Awesome, now no more 20 element array that gets redimed as I pull in entries from the database and wind up 5x20, and me having to hunt back...

    "Okay... Departments(2, 7) is LoanCollections... Batches Completed."
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width