0

Visual Studio では、次のようなデータソースが生成されます。

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

実行すると、「無効なオブジェクト」と表示されます。それから私はそれを見つけました、それはあるべきです

[AdventureWorks].[Person].[Address]

接続文字列は

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

次に、この形式を使用するように VS で構成する方法は?

4

1 に答える 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]
于 2012-05-10T13:43:20.850 に答える