Visual Studio 2015 : SQL Data Source : Unable to retrieve schema. Ensure that the ConnectionString and SelectCommand properties are valid

喜夏-厌秋 提交于 2020-02-04 01:25:44

问题


I have the following development environment for ASP.Net WebPage

VS 2015 Professional Version, using .Net Framework 4.0

MySQL Server 5.6,

MySQL .Net Connector 6.9.5

MySQL for Visual Studio 2.0.2

I am able to connect to the MySQL database server from Visual Studio Server Explorer.

I am trying to create a SQL DataSource for MySQL Database.

When I go through the configure data source wizard, it works fine by populating the tables and columns for each table in "Configure Select Statement form", but then it fails when I try to run the test query in the wizard. It gives errors

"Could Not Create Connection Object reference not set to an instance of an object."

After that I click OK and Finish and the try to refresh schema on the SQLDataSource object in the design view it gives the error

"Unable to retrieve schema. Ensure that the ConnectionString and SelectCommand properties are valid. Object reference not set to an instance of an object." Following code is generated in the aspx file.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:gdsvalueConnectionString %>" 
ProviderName="<%$ ConnectionStrings:gdsvalueConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [sites]">
</asp:SqlDataSource>

And the connection string looks like this in web.config

<connectionStrings>
    <add name="gdsvalueConnectionString" connectionString="server=localhost;user id=root;password=admin;persistsecurityinfo=True;database=gdsvalue"
        providerName="MySql.Data.MySqlClient" />
</connectionStrings>

As a result, I am unable to work with any formviews or grid views which refer that SQL Data Source.

Please help me figure out what is missing in my development environment.

How to get rid of this error ?


回答1:


I just found the solution here. It seems that there is a problem with the plugin for visual studio I installed:

01-mysql-connector-net-6.9.4 CUSTOM UNMARK ASP WEB
02 mysql-for-visualstudio-1.2.7 AND FINALLY:
02-mysql-for-visualstudio-2.0.4

THIS INSTALLER FIXED THE PROBLEM. You have to search for this specific version.




回答2:


I had same problem, you can go to run and run services.msc, then SQL Server(SQLEXPRESS) and start that service. This might help you.



来源:https://stackoverflow.com/questions/39625884/visual-studio-2015-sql-data-source-unable-to-retrieve-schema-ensure-that-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!