Advertisement
Guest User

Untitled

a guest
May 6th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. server IP : 192.168.137.4
  2. Windows Authentication : Windows Authentication
  3. UserName : DELL-M102Zdell
  4. Database : DataProd
  5. Network Protocol : <default>
  6. Product Name : Microsoft SQL Server Express Edition
  7. Server Name : DELL-M102ZSQLEXPRESS
  8. Instance Name : SQLEXPRESS
  9. Computer Name : DELL-M102Z
  10.  
  11. $serverName = "DELL-M102ZSQLEXPRESS"; //serverNameinstanceName
  12. $username = "DELL-M102Zdell"; //serverNameinstanceName
  13. $conn = mssql_connect( $serverName,$username,'');
  14.  
  15. 1. make sure you have allow network connection from sql server configuration tool
  16. 2. allow connection for this port in firewall
  17. 3. activate sql browser service
  18. 4. make sure port is listen as the the service provide
  19.  
  20. <?php
  21. $myServer = 'xxx.xxx.xxx.xxx:yyyy';
  22. $myUser = 'sa';
  23. $myPass = 'xxxxx';
  24.  
  25. $con = mssql_connect($myServer, $myUser, $myPass) or die("Could not connect to database: ".mssql_get_last_message());
  26. if($con){
  27. echo "connected";
  28. }
  29. // Select a database:
  30. mssql_select_db('new')
  31. or die('Could not select a database.');
  32.  
  33. // Example query: (TOP 10 equal LIMIT 0,10 in MySQL)
  34. $SQL = "SELECT TOP 10 * FROM Table";
  35.  
  36. // Execute query:
  37. $result = mssql_query($SQL)
  38. or die('A error occured: ' . mysql_error());
  39.  
  40. // Get result count:
  41. $count = mssql_num_rows($result);
  42. print "Showing $count rows:<hr/>nn";
  43.  
  44. // Fetch rows:
  45. while ($Row = mssql_fetch_assoc($result)) {
  46.  
  47. print $Row['BillNo'] . "n";
  48.  
  49. }
  50.  
  51. mssql_close($con);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement