Mono/C# referencing assemblies using code behind

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bakulaw
    New Member
    • May 2007
    • 2

    Mono/C# referencing assemblies using code behind

    I get this error:

    The type or namespace name `MySql' could not be found. Are you missing a using directive?

    I've already installed Mysql.Data.dll in GAC.

    Im using the "src" tag instead of "CodeBehind " cause im not using VS just a plain text editor in Ubuntu edgy.
  • oohay251
    New Member
    • May 2007
    • 27

    #2
    Don't you want to use the namespace and assembly attribiutes instead of the src attribute.

    Post a snippet man.

    Comment

    • bakulaw
      New Member
      • May 2007
      • 2

      #3
      heres my aspx page:

      <%@ Page Language="C#" src="nns2007.as px.cs" Inherits="_nns2 007" %>
      <html>
      <title>The 7th National Nutrition Survey, year 2007</title>
      <head>Nationa l Nutrition Survey 2007</head>
      <body>
      <form id="form1" runat="server">
      <table>
      <tr>
      <td><input type="text" id="txtareacode " maxlenght="25"> </td>
      </tr>
      <tr>
      <td><input type="text" id="txtht" maxlenght="5"></td>
      </tr>
      <tr>
      <td><input type="text" id="txtwt" maxlenght="5"></td>
      </tr>

      </table>
      </form>
      </body>

      </html>


      my code behind:

      using System;
      using System.Data;
      using System.Configur ation;

      using System.Collecti ons;

      using System.Web;

      using System.Web.Secu rity;

      using System.Web.UI;

      using System.Web.UI.W ebControls;
      using MySql.Data;
      using MySql.Data.MySq lClient;
      using System.Web.UI.H tmlControls;

      public partial class _nns2007 : System.Web.UI.P age
      {




      void connectoDB(stri ng sql)
      {
      string connectionStrin g =
      "Server=localho st;" +
      "Database=anthr o;" +
      "User ID=root;" +
      "Password=sabuk ot;" +
      "Pooling=false" ;
      IDbConnection dbcon;
      dbcon = new MySqlConnection (connectionStri ng);
      dbcon.Open();
      IDbCommand dbcmd = dbcon.CreateCom mand();
      dbcmd.CommandTe xt = sql;
      IDataReader reader = dbcmd.ExecuteRe ader();
      }

      void AnthroInsert()
      {

      string a_INSERT = "INSERT INTO anthro(areacode ,height,weight) VALUES (txtarea,txtht, txtwt)";

      connectoDB(a_IN SERT);
      }


      protected void btnInsert_Click (object sender, EventArgs e)
      {
      AnthroInsert();
      }

      }


      by the way, what version of mysql connector should i use 1.0.5? i

      Comment

      • oohay251
        New Member
        • May 2007
        • 27

        #4
        Likely the mysql assembly does not have a strong name for installation into the GAC.
        Try adding it as a direct reference to your project.

        If that works, peruse "How To Install an Assembly into the Global Assembly Cache in Visual C# .NET" in your .Net documentation

        Comment

        Working...