好吧,我要回答这个问题,然后关闭它,因为虽然我无法得到真正的微软添加数据源的方式,但我以旧式的方式做到了。不是超好的方式,但这只是我学习,所以看到这个例子后,请知道我还有很长的路要走。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using MySql.Data.MySqlClient;
namespace MyFitnessApp
{
public partial class _Default : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
MySqlConnection mss = new MySqlConnection("server=IP Address;Port=####;Database=db_name;Uid=userId;Pwd=password;");
string strSQL = "";
strSQL = "SELECT * FROM TABLE;";
MySqlDataAdapter mda = new MySqlDataAdapter(strSQL,mss);
DataSet myDS = new DataSet();
mda.Fill(myDS,"TABLE");
this.GridView1.DataSource = myDS;
this.GridView1.DataBind();
}
}
}
}
我想弄清楚如何从web.config调用连接字符串,但这是我在几个例子中发现的。
具有讽刺意味的是,我在VB.Net更舒适,我正在学习C#。我发现的例子是用VB.Net编写的,我将它转换为C#。 (:作为MySQL的网站描述为.NET
输入新的连接信息到底在哪? – 2010-10-05 00:13:37
哪个箱子消失了,你在哪里输入什么?(至少MySQL.Data.dll是为MSIL构建,因此处理器无关。 ) – nos 2010-10-05 00:18:05
在我的visual studio 2008(win7 64bit)中工作正常 - 尝试使用toad连接http://toadsoft.com/toadmysql/ – 2010-10-05 00:46:54