Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13
  1. #1

    problema con <%@ Import Namespace = "MySql.Data" %>

    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 senderEventArgs 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(SQLconnection);

    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
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    151
    In c# non devi mettere Import ma using

  3. #3
    ma fra <% %> o no ?
    mi puoi far vedere come e dove ?

    l'intestazione
    <%@ Page Language="C#" %>

    va bene cmq !?

    grazie
    ciao
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  4. #4
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    151
    devi metterlo sempre tra <% %>
    L'errore che dà peò sembra dipendere da altro.
    le dll del connector le hai registrate nella GAC o messe nella directory bin del progetto?

  5. #5
    da cmq lo stesso errore qualche riga + sotto

    Codice PHP:

    <%@ Page Language="C#" %>
    using System.Data;
    using 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 senderEventArgs e)
    {

    MySqlConnection connection = new MySqlConnection();
    connection.ConnectionString "Data Source=localhost; Database=super4; User ID=admin; password=pass";
    connection.Open(); 

    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 'MySqlConnection' could not be found (are you missing a using directive or an assembly reference?)

    Source Error:



    Line 10: {
    Line 11:
    Line 12: MySqlConnection connection = new MySqlConnection();
    Line 13: connection.ConnectionString = "Data Source=localhost; Database=super4; User ID=admin; password=pass";
    Line 14: connection.Open();


    come mai !? :master:
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  6. #6
    no io ho semplicemente installato quell'eseguibile...

    nn so che sia il GAC e nn ho una directory bin nel progetto...

    sono nel panico VVoVe:
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  7. #7
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    151
    intanto crea una directory bin nel progetto e metti le dll del connector mysql in questa directory e vedi se il problema si risolve

  8. #8
    niente... ho provato ma senza buon esito
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  9. #9
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    151
    prova a mettere la dll in una cartella bin sotto wwwroot.
    Può darsi che la cartella dove lavori non sia configurata come applicazione in IIS e quindi IIS cerca la dll nella cartella bin sotto wwwroot

  10. #10
    ma ho registrato anche nella GAC sono sicuro...
    ora provo cmq...
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.