Jump to content

Archived

This topic is now archived and is closed to further replies.

Shazbot!

connecting to SQL 2005

Recommended Posts

My department is migrating from SQL 2000 to SQL 2005. I am trying to connect to the SQL 2005 server but keep getting login failures.

[quote]unable to connect to serverPHP Warning: mssql_pconnect() [function.mssql-pconnect]: message: Login failed for user 'kyle'. (severity 14)[/quote]

I am assuming I can use the same connection string for the SQL 2005 server but just change the server name/username/password.
here's what I have
[code]
$hostname_link ="SQLServer2005";
$database_link = "Moldy_Crow";
$username_link = "kyle";
$password_link = "katarn";
$link = mssql_pconnect($hostname_link, $username_link, $password_link) or die("unable to connect to server");
[/code]

I think the password is incorrect but I am not the server administrator. I wanted to get expert advice if this connection string is correct or if there is something wrong with the code. TIA!

Share this post


Link to post
Share on other sites
By default, SQL Server 2005 is not set up for sql security (will only use windows authentication). You'll have to enable this on your server if you haven't already...

Share this post


Link to post
Share on other sites
ahh, thank you. That does explain a lot.
I can connect to the server with my windows authentication but not with the internet guest account that was created. I will have to see if the administrators of the server enabled this or not. I am just a grunt that connects to the database but not the person who administers the database server.

Share this post


Link to post
Share on other sites
ok,
I can now connect to the database with the other account but now I am having another issue.
I can't get my SQL statement to run from php.

I have a test table called customers in database LEAD with 4 fields (Last_Name, First_Name, etc...)
I created the table under my winNT account.

the table's path looks like: [Domain\MyName_customer].FieldName

I create the following code and execute it:
[code]
require_once('Connect/conn.php');
mssql_select_db("Company");

$SQL_customers=("SELECT First_Name FROM customer");
$Query_display = mssql_query($SQL_customers);

[/code]
Then I get this error:
[quote]PHP Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'customer'. (severity 16)[/quote]

but the table does exist and so does the field.

After this failed, I assumed that since I created this table under my name that the guest account needed permission to view it so I right-clicked on the table, added the guest account with full rights (for testing) and still the same error.

Is there something here that I am missing?
Please help.
Thanks!

Share this post


Link to post
Share on other sites
try
SELECT First_Name FROM Myname.customer
or
SELECT First_Name FROM [Domain\Myname].customer


If it's a permissions issue, you would get a different error message -- this is definitely that the table is in a different schema.

Alternately, you might try
select * from information_schema.tables
and see what it says in there

Share this post


Link to post
Share on other sites
MCP thank you for helping me out. Your suggestion was correct:
[quote]SELECT First_Name FROM [domain\myaccount].customer[/quote]
this worked.

however, my problem now is that I don't want to use my account to access the database online, only the internet guest account that was created. It is a little frustrating because I am using the guest account to connect to the database but I have to use my account to select/ display the items. I am modifying the guest account permissions and trying different things. If you have any additional suggestions it will be most welcome.

Share this post


Link to post
Share on other sites
hmm, you can switch by doing:

alter schema <schema name> transfer <table name>

i think everyone should be able to access the default dbo schema, so maybe use that? or maybe edit the guest.tableName tables to give yourself access?

any of these ways should solve your issues. i wouldn't leave the production tables tied to your account schema, just in case someone else has to take over the project, and then all the names will have to be changed all over the code if you use 2 part names.

Share this post


Link to post
Share on other sites
Thank you MCP,
I will try that. I also picked up a few books and will see if I can correct the problem.
And you're right, I don't want the tables attached to my name.

Share this post


Link to post
Share on other sites
update,
The problem was a permissions issue. I tried setting the permissions on my end but the guest account only had read access.
This was changed by the server admin.

Thanks again for your help!

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.