sql - Can connect with PERL but can't query MSSQL 2k8 database -
i able connect mssql server getting permission error when trying query database. see "yay" in script below, error:
*[microsoft][odbc sql server driver][sql server]the select permission denied on object 'ticket_types', database 'dbname', schema 'dbo'. (sql-42000)(dbd: st_execute/sqlexecute err=-1)*
if add "domain\domain users" dbo access works, when take away doesn't. think it's connecting database logon user, not sql user set in connect string not positive.
the sql driver set use "with sql server authentication using login id..." , not "windows nt..."
classic asp connects , queries fine. can access/query db using sql account in connect string via asp classic , sql server management studio.
it may relevant works against sql2005 not sql2008 trying upgrade to. fine our upgrade except our couple perl scripts don't tables.
use lib "cgi-bin"; use dbi; use cgi; use cgi::carp qw(fatalstobrowser); require "babel.pm"; $y = new babel; $q = new cgi; $server_n = $q->server_name() ; ### connect $database = "dbname"; $dbusername = "sqlusername"; $dbpassword = "sqluserpassword"; $server="sqlserverip"; print "content-type: text/html\n\n"; $dbh = dbi-> connect( "dbi:odbc:driver={sql server}; server=$server; database=$database; uid=$dbusername; pwd=$dbpassword") || die &dberror; if ($dbi::errstr) {print "error: connecting database!"; exit;}else{ print "yay! <br><br>"; } ### end: connect $v2sql = "select distinct route ticket_types"; $css1 = $dbh->prepare ($v2sql); $css1->execute () || print $css1->errstr; while ((@row) = $css1 ->fetchrow_array) { $mana = @row[0]; print "$mana"; } $css1->finish () || print $css1->errstr;
Comments
Post a Comment