Forum Moderators: coopster

Message Too Old, No Replies

Using ADODB with php to connect to a SQL Server DB. Need some help.

         

NooK

1:11 pm on Apr 29, 2008 (gmt 0)

10+ Year Member



I have in the past tried to use the php sql server extension to connect to a sql server database but I gave up upon trying many different things without much success.

I have instead decide to use Adodb which is the only thing I managed to get working but I am unsure on how to handle certani things like errors and status messages.

Here's how I connect to a DB


$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->CursorLocation = 3;
$conn->Open("PROVIDER=SQLOLEDB.1;SERVER=".$DBServer.";DATABASE=".$DBName.";UID=".$DBUsername.";PWD=".$DBPass);

Upon this I use


$conn->execute($query)

To execute queries. My problem is that when I execute things like updates or insertions/deletions I do not know if it was successfull or not (Due to constraints violations and such).

Can anybody help me out?

trevordixon

4:09 pm on Apr 29, 2008 (gmt 0)

10+ Year Member



I imagine the execute() function would return something about the success or failure of the operation. Try doing

echo $conn->execute($query);

and see what it tells you.

NooK

2:14 pm on Apr 30, 2008 (gmt 0)

10+ Year Member



This is what I get (As expected)


Catchable fatal error: Object of class variant could not be converted to string in filePath on line 1933

var_dump on the other hand outputs

object(variant)#5 (0) { }

As you can see it returns a variant thus I am not sure there's anyway to know what ti actually returns (When not returning the result ofc) without knowing the workings of the protocol behind it which is what I was hoping someone with a bit more experience in ADODB could help me with.