Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Help! Local DB Not Working.

Author  Topic 

dineshkunder
Starting Member

9 Posts

Posted - 2005-09-07 : 19:54:50
Hello, Thanks in Advance.

I have SQL Server installed on my XP pc and just set up PWS so I can test out my asp pages accessing SQL db's locally. Everything runs great when I access the NorthWind database via an ASP page using the SA account.

But when I try to run a page from a Functioning Website I get an error saying that the object cannot be found like so:

Invalid object name 'profile_players'.

I had backed up the db and restored it locally and can view the tables/procs/data etc. fine in Enterprise Manager but cannot access the tables via ASP or Query Analyzer. The ASP code for the connections is fine and I can connect via ASP to the db, because if I mess with the password login fails. So I know the db exists and can be connected to, but no pages are working or even the simplest of queries. Basically I get the error, invalid object.

I have made sure that the database names on my WebHost and local are the same and such..Is this something to do with permissions or using aliases in my queries for tables etc.?

select * from profile_players - > does not work

sselect * from gamesdb.profile_players - > does not work

Any ideas/help would be greatly appreciated!!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-07 : 20:16:52
You probably need the three part naming convention: DbName.OwnerName.ObjectName. If your OwnerName is dbo like most will be, then you'll use gamesdb.dbo.profile_players. Or your connection string can specify the database name so that you only need the two part naming convention: OwnerName.ObjectName.

Tara
Go to Top of Page

dineshkunder
Starting Member

9 Posts

Posted - 2005-09-08 : 09:47:10
Thanks! That worked but is there any way around this cos there are too many front end pages that I will have the change the code on going back and forth between my local and production servers....
Go to Top of Page

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-09-08 : 11:09:18
put your connection string in one file (like an .inc in classic ASP) and refer to that file on all pages. And between your production and development boxes you have different connection string files.

====================================================
Regards,
Sean Roussy

"pimpin ain't easy, but someone has to do it" -- Pimpin Whitefolks(?)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-08 : 13:10:39
If this is .NET, then store your connection string in the app.config. Here is a sample:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Data Source" value="SomeServer"/>
<add key="Initial Catalog" value="SomeDatabase"/>
<add key="Application Name" value="My App"/>
<add key="Connection Timeout" value="15"/>
</appSettings>
</configuration>

And here's the sample call to build the connection string (VB.NET):

ConnStr = "Data Source=" & ConfigurationSettings.AppSettings("Data Source") & ";" & _
"Initial Catalog=" & ConfigurationSettings.AppSettings("Initial Catalog") & ";" & _
"Integrated Security=SSPI;" & _
"Application Name=" & ConfigurationSettings.AppSettings("Application Name") & ";" & _
"Connection Timeout=" & ConfigurationSettings.AppSettings("Connection Timeout") & ";" & _
"Persist Security Info=False;"

Then to use ConnStr for your connection:
connectionName.ConnectionString = ConnStr

Tara
Go to Top of Page
   

- Advertisement -