• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

same statement in sql 2005

hello:

i'm using php,  and datasource and odbc connection to connect a sql 2005 server

could some expert here tell what is the same statement i shoudl use in sql 2005?
mssql_num_rows(): // this van be used in sql 2000, but not in sql 2005

mssql_query();// this van be used in sql 2000, but not in sql 2005

also mssql_close() ;
----------------------------------------------
coud i use the following to know the number of rows returned:?
odbc_exec($dsn, $SQL);
$row = odbc_fetch_array($result)
$rowNum = sizeof ($row );
----------------------------------------------
thank you so much for your help. i'm totally new to ms sql 2005
0
lilyyan
Asked:
lilyyan
  • 4
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
actually, mssql functions should work for sql 2000 and sql 2005 the same?
I do use mssql_query with sql 2005, actually...
0
 
lilyyanAuthor Commented:
well, i got this error: mssql_num_rows(): supplied resource is not a valid MS SQL-result resource in myfile.php in line 20
0
 
lilyyanAuthor Commented:
these three lines are i used:
$dsn =odbc_connect($mssqlDatasource, $mssqlUser, $mssqlPass, SQL_CUR_USE_ODBC);
$result=odbc_exec($dsn,"SELECT Name FROM myTable;");
$num= mssql_num_rows($result);

thank you so much!
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
when using odbc_connect, you "obviously" cannot use mssql_num_rows....
instead, guess what: odbc_num_rows():
http://php.net/manual/en/function.odbc-num-rows.php
0
 
lilyyanAuthor Commented:
thank you so much:

would you please suggetsion which are the same functions for :
mssql_query(); // this can be used in sql 2000, but not in sql 2005

also mssql_close() ;// this can be used in sql 2000, but not in sql 2005
----------------------------------------------
coud i use the following to know the number of rows returned:?
odbc_exec($dsn, $SQL);
$row = odbc_fetch_array($result)
$rowNum = sizeof ($row );
----------------------------------------------
well, i post these in the begainning, so it's still the same question, thank you so much!
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>mssql_query(); // this can be used in sql 2000, but not in sql 2005
>also mssql_close() ;// this can be used in sql 2000, but not in sql 2005

as I said, I do use mssql_xxxxx  functions on both sql 2000 AND sql 2005, so if you fail to use them, you probably only need to connect correctly, ie:

mssql_connection("servername,port","username", "password");

the ",port" part is the "trick" to get it working with sql 2005...
0
 
lilyyanAuthor Commented:
when i add port, i couldn't connect to the database
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you will have to get the right port, of course.
also, what is the OS you run php on?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now