Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Information From MS SQL Stored Procedure 1

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
How do I get information from a stored procedure in MS SQL

I can run a query directly from the database.

Here is the code that I have being trying

Code:
$db = mssql_connect("server","user","password") or die("Unable to connect to server");
$db = mssql_select_db("database");

$query = mssql_init("ProcedureName",$db);
$result = mssql_execute($query) or die("QUERY FAILED"); 

print("<table border=1>");
print("<tr><th>Header 1</th><th>Header 2</th></tr>");
while ($row = mssql_fetch_object($result)) {
print("<tr>");
printf("<td>%s</td>", $row->FirstName);
printf("<td>%s</td>", $row->LastName);
print("</tr>");
}
print("</table>");

I am getting the query failed error

Thanking in advance for any help received
 
You're assigning $db to the database connection, and to the open database ... remove $db = from the select db line, and you'll be good to go.



Greg

"for me, the action is the juice.
 
Hi grtammi
I changed the code according to your suggestion.
Thank you.

But I also discovered that the username I was using didn't have permissions to execute the stored procedure.


I can now run stored procedures.
 
not a problem ... thanks for the star!

Greg

"for me, the action is the juice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top