Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Test koneksi ke MS SQL Server
- */
- /* specify the server and connection string attributes */
- $serverName = "win7\SQLEXPRESS";
- $connectionInfo = array("Database"=>"latihan");
- /* Connect using Windows Authentication */
- $con = sqlsrv_connect($serverName, $connectionInfo);
- if($con == false){
- echo "Unable to connect.</br>";
- die(print_r(sqlsrv_errors(), true));
- }
- /* Query SQL Server for the login of the user accessing the database. */
- $tsql = "select * from pegawai";
- $stmt = sqlsrv_query($con, $tsql);
- if($stmt === false){
- echo "Error in executing query.</br>";
- die(print_r(sqlsrv_errors(), true));
- }
- /* Retrieve and display the results of the query */
- $row = sqlsrv_fetch_array($stmt);
- echo "ID Pegawai : ".$row[0]."</br>";
- echo "Nama Pegawai : ".$row[1]."</br>";
- echo "Alamat Pegawai : ".$row[2]."</br>";
- /* Free statement and connection resources. */
- sqlsrv_free_stmt($stmt);
- sqlsrv_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement