Visual Studio 2015:SQL数据源:无法检索架构。确保ConnectionString和SelectCommand属性有效 [英] Visual Studio 2015 : SQL Data Source : Unable to retrieve schema. Ensure that the ConnectionString and SelectCommand properties are valid

查看:606
本文介绍了Visual Studio 2015:SQL数据源:无法检索架构。确保ConnectionString和SelectCommand属性有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下ASP.Net WebPage开发环境

I have the following development environment for ASP.Net WebPage

VS 2015 Professional Version,使用.Net Framework 4.0

VS 2015 Professional Version, using .Net Framework 4.0

MySQL服务器5.6,

MySQL Server 5.6,

MySQL .Net连接器6.9.5

MySQL .Net Connector 6.9.5

适用于Visual Studio 2.0的MySQL .2

MySQL for Visual Studio 2.0.2

我能够从Visual Studio Server Explorer连接到MySQL数据库服务器。

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

我是尝试为MySQL数据库创建SQL数据源。

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."

之后,我单击确定,然后单击完成,然后尝试在设计视图中刷新SQLDataSource对象上的架构,则会出现错误

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

无法检索架构。请确保ConnectionString和SelectCommand属性有效。对象引用未设置为对象的实例。
在aspx文件中生成以下代码。

"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>

连接字符串在web.config中看起来像这样

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>

结果,我无法使用任何引用该SQL数据源的formview或网格视图。

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 ?

推荐答案

我遇到了同样的问题,您可以运行并运行 services.msc ,然后是SQL Server(SQLEXPRESS)并启动该服务。这可能会对您有所帮助。

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.

这篇关于Visual Studio 2015:SQL数据源:无法检索架构。确保ConnectionString和SelectCommand属性有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆