sunilvadranapu Posted February 7, 2008 Share Posted February 7, 2008 Hi, did any one know how to connect to teradata from PHP with dsn less connection. I am getting error while trying with below code - ODBC error: [DataDirect][ODBC lib] Invalid string or buffer length ODBC error code: S1090 Code: <?php $con_string = "DRIVER={Teradata};DBCName=sunil; DATABASE=DBC; if (!($this->connection_id = @odbc_connect( $con_string, ****, *****)) ){ echo "Connection Failed"); } else { echo "Connected to DB..."."\n"; } ?> Can any one tell me whats the problem in this code. thanks in advance -sun Quote Link to comment Share on other sites More sharing options...
haku Posted February 7, 2008 Share Posted February 7, 2008 Please use [ code ] tags around your code. Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted February 7, 2008 Author Share Posted February 7, 2008 i am able to connect with DSN but could not with connection string $con_string = "DRIVER={Teradata};DBCName=sunil;DATABASE=DBC"; could any one help me to come out of this problem thanks in advance -sun Quote Link to comment Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Find the correct connection string basically. Whatever your DSN has is different to what you're using. And what's wrong with using a DSN instead? They're essentially the same thing seeing as they both rely on a driver to work. Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted February 27, 2008 Author Share Posted February 27, 2008 I am able to connect to Teradata using DSNless connection in windows but failing in Linux. my code is function ConnectDB($host, $username, $password, $options="") { $con_string = "DRIVER={Teradata};DBCName=" . $host ."; DATABASE=DBC; RunInQuietMode=Yes"; if (!($this->connection_id = @odbc_connect($con_string,$username,$password)) ){ $this->report_error("\nConnection Failed.....\n"); exit; } else { echo "\nConnected to ". $host. " DB..."."\n"; return $this->connection_id; } }//end of connectDB [/Code] The above code is working fine in Windows but resulting below errors in Linux ODBC error: [DataDirect][ODBC lib] Invalid string or buffer length ODBC error code: S1090 I think we can use odbc_connect() function for both DSN and DSNless connections. As per my knowledge, odbc_connect() when used with DSN connection, calls SQLConnect(). But when used with DSNless connection calls SQLDriverConnect(). But when i checked my driverTrace, i observed that odbc_connect in linux calling SQLConnect() eventhough i am passing DSNless connection string. could any one help in this regard. thanks in advance -sunil Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted February 28, 2008 Author Share Posted February 28, 2008 any suggestions on this? Quote Link to comment Share on other sites More sharing options...
aschk Posted February 28, 2008 Share Posted February 28, 2008 You don't have the teradata driver in linux, hence your issue. There's nothing wrong with the ODBC call, just the string you're giving it. The linux driver for teradata doesn't exist. Hence to correct your problem, install the teradata linux driver on the machine in question. Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted March 7, 2008 Author Share Posted March 7, 2008 Thanks for your reply. teradata ODBC driver is already installed on my system and able to connect to teradata with DSN. with Teradata ODBC driver, we even can't connect with DSN. any suggestions?? thanks, -sunil Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted March 11, 2008 Author Share Posted March 11, 2008 do we need to configure anything in php.ini for Teradata? if so, could you let me know the configurations that need from PHP side thanks, -sunil Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted May 12, 2008 Author Share Posted May 12, 2008 Could any one tell me what is the connection string for Teradata to connect from PHP. I have installed tdodbc and tried to run above sample program. Could you help me in this regard. thanks in advance -sun Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.