How To Disconnect from a SQL Server using mssql_close()?
Submitted by: AdministratorWhen you call mssql_connect(), it will return an object representing the connection to the SQL Server. This connection object will be used by subsequent MSSQL function calles. When you are done with this connection, you should close it to free up resources by calling the mssql_close() function.
The tutorial script below shows you how to call mssql_connect() and mssql_close() to connect and disconnect to the SQL Server:
<?php
$con = mssql_connect('LOCALHOST','sa','GlobalGuideLine');
if (!$con) {
print("Connection failed with error. ");
} else {
print("The SQL Server connection object is ready. ");
mssql_close($con);
}
?>
If you run this script and get this output: "The SQL Server connection object is ready", your connection to the SQL Server are working.
Note that 'sa' and 'GlobalGuideLine' used in this script are system administrator login name and password. You may use any other login name and password defined on the SQL Server.
Submitted by: Administrator
The tutorial script below shows you how to call mssql_connect() and mssql_close() to connect and disconnect to the SQL Server:
<?php
$con = mssql_connect('LOCALHOST','sa','GlobalGuideLine');
if (!$con) {
print("Connection failed with error. ");
} else {
print("The SQL Server connection object is ready. ");
mssql_close($con);
}
?>
If you run this script and get this output: "The SQL Server connection object is ready", your connection to the SQL Server are working.
Note that 'sa' and 'GlobalGuideLine' used in this script are system administrator login name and password. You may use any other login name and password defined on the SQL Server.
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Convert Binary Strings into Integers in MS SQL Server? |
☺ | What Happens If You Insert a Duplicate Key for the Primary Key Column in MS SQL Server? |
☺ | Does Index Slows Down INSERT Statements? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | Can You Roll Back the DDL Statement in a Trigger? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |