Ciao
ho installato il connector preso da qui http://dev.mysql.com/downloads/connector/net/1.0.html sul mio server.
ho creato una semplice pagina c# da uno script trovato sul forum (posto il codice)
Codice PHP:
<%@ Page Language="C#" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
MySqlConnection connection = new MySqlConnection();
connection.ConnectionString = "Data Source=localhost; Database=supe4; User ID=admin; password=pass";
connection.Open();
string SQL = "select * from fotografie";
MySqlCommand cmd = new MySqlCommand(SQL, connection);
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Response.Write("Titolo : " + dr["nome"] + " - data_ins : " + dr["data_ins"] + "
");
}
}
dr.Close();
connection.Close();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
ed ottengo questo errore
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 1: <%@ Page Language="C#" %>
Line 2: <%@ Import Namespace = "System.Data" %>
Line 3: <%@ Import Namespace = "MySql.Data" %>
Line 4: <%@ Import Namespace = "MySql.Data.MySqlClient" %>
Line 5: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
la cosa strana è che su un progetto identico scritto in VB che si collega allo stesso server mysql (altro db chiaramente) funziona tutto correttamente...
cioè la connessione a mysql funziona e non mi da alcun problema sui namespace.
cosa posso fare ?
grazie