[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

same statement in sql 2005

Posted on 2008-10-01
8
Medium Priority
?
281 Views
Last Modified: 2012-05-05
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
Comment
Question by:lilyyan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22619648
actually, mssql functions should work for sql 2000 and sql 2005 the same?
I do use mssql_query with sql 2005, actually...
0
 

Author Comment

by:lilyyan
ID: 22623318
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
 

Author Comment

by:lilyyan
ID: 22623351
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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 22623386
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
 

Author Comment

by:lilyyan
ID: 22623708
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22623835
>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
 

Author Comment

by:lilyyan
ID: 22624480
when i add port, i couldn't connect to the database
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22625683
you will have to get the right port, of course.
also, what is the OS you run php on?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question