|
- <?php
- /* Connect to the local server using Windows Authentication and
- specify the AdventureWorks database as the database in use. */
- $serverName = "192.168.104.124";
- $connectionInfo = array("UID"=>"sa", "PWD"=>"0", "Database"=>"southeast");
- $conn = sqlsrv_connect( $serverName, $connectionInfo);
- if( $conn === false )
- {
- echo "Could not connect.\n";
- die( print_r( sqlsrv_errors(), true));
- }
- /* Set up and execute the query. */
- $tsql = "select * from Vender";
- $stmt = sqlsrv_query( $conn, $tsql, array());
- if( $stmt === false)
- {
- echo "Error in query preparation/execution.\n";
- die( print_r( sqlsrv_errors(), true));
- }
- /* Retrieve each row as an associative array and display the results.*/
- $i =0;
- while( $row = sqlsrv_fetch_array( $stmt))
- {
- echo $row['ID'].", ".$row['CompanyName']."<br>";
- $i++;
- }
- echo $i;
- /* Free statement and connection resources. */
- sqlsrv_free_stmt( $stmt);
- sqlsrv_close( $conn);
- ?>
复制代码 为什么以上只会输出一条,不会循环输出。
|
|