To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > Windows Help

Windows Help Help with the Windows operating system

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-02-2000, 07:07 AM   #1
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,386
How can I create a MS SQLServer connection

How can I create MS SQLServer connection,and how can I open a SQLServer database in PHP4?
in ASP,I can use:
set objDB = Server.CreateObject("ADODB.Connection")
set objRS = Server.CreateObject("ADODB.RecordSet")
objDB.Open "DateBase", "user", ""
set objRS = objDB.Execute( SQLStr )
but how can I do it in php4?

I tried mssql_connect(SQLServer),but IIS tell me he can't find function mssql_connect().
Anon is offline   Reply With Quote
Old 08-02-2000, 09:03 AM   #2
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,386
RE: How can I create a MS SQLServer connection

You may need ntwdblib.dll
Anon is offline   Reply With Quote
Old 08-02-2000, 03:21 PM   #3
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,386
RE: How can I create a MS SQLServer connection

You must first create an ODBC dsn in control panel.

This code will work:

$conn = odbc_connect("DataSourceName", "Username", "Password");

Then query the database:

$q = "select field from table";
$results = odbc_do($conn, $q);

while(odbc_fetch_into($results, &$row)) {
$field = $row[0];
//do something with data
}
Anon is offline   Reply With Quote
Old 08-03-2000, 04:34 AM   #4
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,386
RE: How can I create a MS SQLServer connection

You could always talk to it as a Sybase DB, since MSSQL (up to 6.5 anyways, and 7.0 is compatible) is really a Sybase DBMS covered in Microsoft gooey dressing.

Make sure you are using the Sybase libraries, or there will be trouble. This works fine from Linux with sybase-ct compiled in and Sybase-ASE drivers in /home/sybase. I assume the Sybase DLL under NT will perform as well or better than ODBC as the sybase-ct code under Linux beats ODBC in speed from what I can tell.

$dbms = "dns.server.name";
$user = "username";
$pass = "password";

$cs = sybase_connect($dbms, $user, $pass);
sybase_query("USE databasename", $cs);

or

sybase_select_db("databasename", $cs);

$rs = sybase_query("SQL", $cs);

$result_array = sybase_fetch_array($cs);

sybase_free_result($rs);
sybase_close($cs);

Give that a try, that's what we use on our website against an MSSQL 6.5 NT box. Tis quick too. (not as fast as MySQL, but I love my triggers and stored procedures, NT hohum)

Chris
Anon is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:50 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.