Wednesday, March 7, 2012

mssql_connect problems

hi i'm new user of sql server.....
before i used sql server,i'm mysql user..

at my program i have 2 server,so if i used mysql i used this :

$mysqli1 = mysqli_connect("$DbHostName1", "$DbUserName1", "$DbPassWord1", "$DatabaseName1");
$mysqli2 = mysqli_connect("$DbHostName2", "$DbUserName2", "$DbPassWord2", "$DatabaseName2");

so if i want to get query from server 2,i just do this :

$select = mysqli_query($mysqli2,"select * from `home`");

and if i want to get query from server 1,i do this :

$select = mysqli_query($mysqli1,"select * from `home`");

the problem is i want to change mysql to sql_server,so how to connect to 2 server like i do at mysql,and how to get the query ?

thanks...nobody can't help me ?

em...|||Try this syntax.
Replace needful

SELECT *
FROM OPENDATASOURCE(
'SQLOLEDB',
'Data Source=servername;User ID=username;Password=password'
).databasename.dbo.tablename
Good luck.

No comments:

Post a Comment