[英]read sql schema in sqldatasource
I am using some SQL schema in my database, 我在我的数据库中使用了一些SQL模式,
CoursesProperties.tbl_Countries
CoursesProperties.tbl_Rating
In my .net application, I am using a SqlDataSourse
to fill a GridView straight forward 在我的.net应用程序中,我使用
SqlDataSourse
直接填充GridView
<asp:SqlDataSource ID="SqlDataSourceLocations" runat="server"
ConnectionString="<%$ ConnectionStrings:TrainingConnectionString %>"
SelectCommand="SELECT CountryE FROM [CourseProperties.tbl_Countries]">
</asp:SqlDataSource>
When I run my application I am getting this error: 当我运行我的应用程序时,我收到此错误:
Invalid object name 'CourseProperties.tbl_Countries'.
无效的对象名称'CourseProperties.tbl_Countries'。
Even if I remove the schema I getting error 即使我删除了架构,我也会收到错误
Invalid object name 'tbl_Countries'.
无效的对象名称'tbl_Countries'。
I thought about removing the schema from the database, but I thought let's first seek help from the experts. 我想从数据库中删除模式,但我想我们首先寻求专家的帮助。
Any suggestion? 有什么建议吗?
The square brackets should be: 方括号应为:
SelectCommand = "SELECT CountryE FROM [CourseProperties].[tbl_Countries]"
or omit them completely: 或者完全省略它们:
SelectCommand = "SELECT CountryE FROM CourseProperties.tbl_Countries"
but not around the schema AND table name 但不在架构和表名称周围
[Square brackets are required only if you use spaces, keywords or special characters in column names (or identifiers), which you should try to avoid.] [仅当您在列名(或标识符)中使用空格,关键字或特殊字符时才需要使用方括号,但应尽量避免使用方括号。]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.