douju6850 2014-10-10 16:44
浏览 63
已采纳

尝试将托管的Web应用程序连接到本地数据库?

I am trying to connect hosted webs application to Local database. First I was getting Fatal error: Call to undefined function odbc_connect() error but after add the "odbc" extension i started getting

Error connecting to the ODBC database: [unixODBC][Driver Manager]Data source name not found, and no default driver specified

I used the following code in php script to connect to the Local database using ODBC

$odbc['dsn'] = "SageLine50v19";
$odbc['user'] = "Peac";
$odbc['pass'] = "XXXX";
$mysql['host'] = "localhost";
$mysql['user'] = "root";
$mysql['pass'] = "";
$mysql['dbname'] = "sagetest";
$mysql['idfield'] = "id";


// Step 1: Connect to the source ODBC database
if ($debug) echo "Connect to " . $odbc['dsn'] . ' as ' . $odbc['user'] . "
";
$conn = odbc_connect($odbc['dsn'], $odbc['user'], $odbc['pass']);
if (!$conn) {
die("Error connecting to the ODBC database: " . odbc_errormsg());
}

// loop through each table 
$allTables = odbc_tables($conn);
$tablesArray = array();
while (odbc_fetch_row($allTables)) {
 if (odbc_result($allTables, "TABLE_TYPE") == "TABLE") {
    $tablesArray[] = odbc_result($allTables, "TABLE_NAME");
 }
}
 //print_r($tablesArray);      // to list all tables

My ODBC.ini looks like below

[ODBC 32 bit Data Sources]
t=SQL Server Native Client 10.0 (32 bit)
SageLine50v19=Pervasive ODBC Client Interface (32 bit)

[t]
Driver32=C:\Windows\system32\sqlncli10.dll
[SageLine50v19]
Driver32=C:\Program Files (x86)\Pervasive Software\PSQL\bin\w3odbcci.dll
  • 写回答

2条回答 默认 最新

  • duanmu5641 2014-10-11 04:58
    关注

    Error connecting to the ODBC database: [unixODBC][Driver Manager]Data source name not found, and no default driver specified

    Problem:

    This is your data source name:

    [ODBC 32 bit Data Sources]
    

    But in your php you put

    $odbc['dsn'] = "SageLine50v19";
    

    Solution:

    Decide wich one you change:

    odbc.ini

    [SageLine50v19]
    

    or php

    $odbc['dsn'] = "ODBC 32 bit Data Sources";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统