0

In the Visual Studio, it will generate datasource like this :

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString1 %>" 
        SelectCommand="SELECT top 10 * FROM [Address]">
    </asp:SqlDataSource>

when run it, it will say 'invalid object'. then I found it out, it should be

[AdventureWorks].[Person].[Address]

The connection string is

 <connectionStrings>
        <add name="AdventureWorksConnectionString1" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

Then how to config in VS to use this format ?

1
  • What does your connection string look like? Maybe apart from what Oded already pointed out, the Initial Catalog=AdventureWorks is missing and your query is directed against the master database. Commented May 10, 2012 at 13:48

1 Answer 1

2

The default schema for the logged in database user is probably [dbo], not [Person]. You need to qualify the schema name in such a case.

Your select command should be:

SELECT top 10 * FROM [Person].[Address]
Sign up to request clarification or add additional context in comments.

1 Comment

@user595234 - Apologies, you are correct. You need to qualify the schema if the user is not setup to use that one by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.