L'errore che mi dà è il seguente:
codice:
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][Driver Manager ODBC] Nome origine dati non trovato e driver predefinito non specificato., SQL state IM002 in SQLConnect in C:\xampp\htdocs\test.php on line 5 odbc not connected
Ecco anche il codice della pagina:
codice:
<?php
//connect to a DSN "myDSN"
$conn = odbc_connect('Provider=SQLOLEDB.1;Persist Security Info=False;Initial File Name=C:\Users\andrea\Desktop\DataBase\1.mdf','sa','admin');
if ($conn)
{
//the SQL statement that will query the database
$query = "select * from Dat_Config";
//perform the query
$result=odbc_exec($conn, $query);
echo "<table border=\"1\"><tr>";
//print field name
$colName = odbc_num_fields($result);
for ($j=1; $j<= $colName; $j++)
{
echo "<th>";
echo odbc_field_name ($result, $j );
echo "</th>";
}
//fetch tha data from the database
while(odbc_fetch_row($result))
{
echo "<tr>";
for($i=1;$i<=odbc_num_fields($result);$i++)
{
echo "<td>";
echo odbc_result($result,$i);
echo "</td>";
}
echo "</tr>";
}
echo "</td> </tr>";
echo "</table >";
//close the connection
odbc_close ($conn);
}
else echo "odbc not connected";
?>