database access problem through cgi script

Discussion in 'Ruby' started by Raju Alluri, Dec 28, 2008.

  1. Raju Alluri

    Raju Alluri Guest

    Hi,
    I am trying to print a set of data from database with a CGI script. This
    script works fine a simple ruby script. But doesnt work in cgi script.
    Any help is appreciated.


    connection = WIN32OLE.new('ADODB.Connection')
    connection.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=C:\INFOPROJECT\db1.mdb')
    recordset = WIN32OLE.new('ADODB.Recordset')
    sql = "select * from GuestBook"
    recordset.Open(sql, connection)
    data = recordset.GetRows #.transpose
    puts data
    recordset.Close
    connection.close

    How can i call the above statements in below cgi script to make it work.

    #!/usr/bin/ruby
    require 'win32ole'
    require 'cgi'

    cgi = CGI.new("html3")
    cgi.out() do
    cgi.html() do
    cgi.head{ cgi.title{"DATABASE"} } +
    cgi.body() do
    cgi.form() do
    cgi.textarea("get_text") +
    cgi.br +

    end
    end
    end
    --
    Posted via http://www.ruby-forum.com/.
     
    Raju Alluri, Dec 28, 2008
    #1
    1. Advertising

  2. Raju Alluri

    Tony Lawetta Guest

    Raju Alluri wrote:
    > Hi,
    > I am trying to print a set of data from database with a CGI script. This
    > script works fine a simple ruby script. But doesnt work in cgi script.
    > Any help is appreciated.


    When calling it on the console it is you (i.e. the user ID you are
    logged in with).
    When calling the CGI it is the webserver (i.e. the user ID under which
    it is running) that is executing your code.

    Are you sure that the webserver has the permission to connect to the DB?

    T.
     
    Tony Lawetta, Dec 28, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JC
    Replies:
    3
    Views:
    611
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=
    Jun 19, 2006
  2. praba kar

    Python-cgi or Perl-cgi script doubt

    praba kar, Jul 30, 2005, in forum: Python
    Replies:
    1
    Views:
    812
    Michael Sparks
    Jul 30, 2005
  3. Amir  Michail

    cgi relay for python cgi script

    Amir Michail, Oct 4, 2005, in forum: Python
    Replies:
    7
    Views:
    498
    Michael Ekstrand
    Oct 4, 2005
  4. Muzammil
    Replies:
    1
    Views:
    1,284
    red floyd
    Aug 28, 2008
  5. kath
    Replies:
    4
    Views:
    814
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page