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.
Author |
Topic |
rasher83
Starting Member
24 Posts |
Posted - 2008-06-02 : 18:58:16
|
Hi, I will post this on a c# forum as well but maybe someone has an answer here.I want to connect to my database in a program i am coding with C#.I have 3 databases in my SQL server (DB1, DB2, DB3)(perhaps schemas is the word to use) all under a connection called TEST (as opposed to SQLEXPRESS.My connection string in my code is as follows:string ConnectionString = "Data Source=.\\TEST;Integrated Security=True;Connect Timeout=30;User Instance=True;";My app reports a valid connection is made. WooHoo.But,When i try to do a select statement eg: Select * from DB1.CustomersI get the following error.System.Data.SqlClient.SqlException: Invalid object name 'DB1.Customers'I have tried removing the DB1. part from the select statement and specifying Database = DB1 in my connection string but that doesnt work either.Any help provided would be greatly appreciated.Thanks. |
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2008-06-02 : 19:31:57
|
quote: Select * from DB1.Customers
Did you try select * from DB1..Customers Do you have access to Customers Table in DB1?quote: I have tried removing the DB1. part from the select statement and specifying Database = DB1 in my connection string but that doesnt work either.
What is the error here?ThanksKarunakaran |
|
|
rasher83
Starting Member
24 Posts |
Posted - 2008-06-04 : 11:58:11
|
I managed to get this resolved by altering the connect string to the following:"Data Source=.\\TEST;AttachDbFilename=\"C:\\TEST\\Database\\MSSQL.1\\MSSQL\\Data\\DB1.mdf"thanks |
|
|
|
|
|