Answers

Question and Answer:

  Home  MS SQL Server

⟩ How To List All DSN Entries on Your Local Machine using odbc_data_source()?

If you are interested to know what DSN entries are available on your local machine, you can use odbc_data_source($con, SQL_FETCH_FIRST) and odbc_data_source($con, SQL_FETCH_NEXT) in a loop to list all DSN entries defined on your local machine. The tutorial script below shows a good example:

<?php

$con = odbc_connect('ggl_SQL_SERVER','sa','GlobalGuideLine');

if (!$con) {

print("There is a problem with the connection. ");

} else {

print("The ODBC connection object is ready. ");

$list = odbc_data_source($con, SQL_FETCH_FIRST);

while ($list) {

foreach ($list as $key => $value) {

print($key . " = " . $value . " ");

}

$list = odbc_data_source($con, SQL_FETCH_NEXT);

}

odbc_close($con);

}

?>

 174 views

More Questions for you: