0
好吧,我一直在访问我的网站的MySQL数据库。我能够完美地连接,并从数据库中插入和选择东西。Visual Studio配置数据源MySQL
server = "localhost";
database = "datamain";
uid = "root";
password = "fakepassword";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
connection = new MySqlConnection(connectionString);
现在我想放在一个列表视图。然后我去选择新的数据源。然后我把所有的数据和测试连接都放进去了,所以我点击好了。现在我完成了,所以我点击完成。于是说:
The data provider "MySQL.data.MySQLClient could not be found in the system configuration. Unable to find the requested .NET framework Data provider. It may not be installed
是的,我在斌的参考,因为它让我手动连接到数据库
UPDATE:我甚至可以手动得到一个数据源
try
{
String sCon = "SERVER=localhost;DATABASE=datamain;UID=root;PASSWORD=fakepassword";
MySqlConnection con = new MySqlConnection(sCon);
String s = "Select * from tb_login";
MySqlDataAdapter dat = new MySqlDataAdapter(s, con);
DataSet ds = new DataSet();
dat.Fill(ds, "tb_login");
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
}
而我的web.config看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
</compilation>
</system.web>
</configuration>
是的,我发现。另外我发现我可以手动连接。我上面更新了我的代码。 – Beastwood