using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.Types;
using System.Data;
using System.Data.Odbc;
using MySql.Data.MySqlClient;
namespace WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//MySqlConnection connectionString = "server=localhost;" + "Database=xd;" + "Uid=root;" + "Pwd=rklzbfot;" + "pooling=false;";
String strProvider = "Data Source=localhost;" + "Database=xd;" + "User ID=root;" + "Password=rklzbfot";
MySqlConnection myConnection = new MySqlConnection(strProvider);
myConnection.Open();
String MyConState = myConnection.State.ToString();
string sSql;
sSql = "SELECT * FROM Product";
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(sSql,myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "myQuery1");
GridView1.DataSource = myDataSet.Tables["myQuery1"];
GridView1.DataBind();
myConnection.Close();
}
}
}
ตอนนี้รันแล้ว เกิด error ที่ page ว่า Code (PHP)
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 5: using System.Web.UI;
Line 6: using System.Web.UI.WebControls;
Line 7: using MySql.Data.Types;
Line 8: using System.Data;
Line 9: using System.Data.Odbc;
Source File: c:\Users\ZieIw\Documents\Visual Studio 2010\Projects\WebApplication3\WebApplication3\WebForm1.aspx.cs Line: 7
Show Detailed Compiler Output:
Show Complete Compilation Source:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1