c# - Getting CS0246 when making ASP.NET-web application but MySql.Data is added -


Thank you first for trying to solve my problem.

I am doing a webplication with ASP.net in the background with C # so when a user pushes the button on login.aspx, then Administratie.login () is registered with the login name and password. Is called together. The Administratie tells the database to execute its own login (cs) in which it creates a connection to the database.

login.aspx:

  using the system; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using System.Web.UI; Using System.Web.UI.WebControls; Using MySql.Data.MySqlClient; Namespace Admin_SiM.Forms {Public Partial Class Login: System. Web.UI.Page {Private Administrator Administrator; Protected Zero Page_load (object sender, event aRGS) {administratie = new Adminstratie (); } Secure zero btLogin_Click (object sender, EventArgs e) {string result = administratie.login (tbEmail.Text, tbWachtwoord.Text); Errorlabel.Text = Results; If (results == "right") {// go to next screen}}}}  

Administratie.cs:

  using the system; Using System.Web; Using System.Web.Services; Using System.Web.Services.Protocols; Using System.ComponentModel; Using System.Collections.Generic; Namespace Admin_SiM {public class administrator {personal database db; Public Administrator () {db = New Database (); } Public String Login (String Email, String Password) {string result = db.Login (email, password); Return result; }}}  

Database.cs:

  using MySql.Data.MySqlClient; Using the system; Namespace Admin_SiM {Public class database {MySqlConnection con; Public database () {string constring = "server = 127.0.0.1; uid = root; pwd = obsessed; database = SIM;"; Try {con = new MySqlConnection (constring); Con.Open (); } Hold (MySqlException pre) {string errormessage = ex.StackTrace; Console.WriteLine (error message); } Finally {con.Close (); }} Public String Login (String Username, String Password) {try {con.Open ()} MySqlCommand CMD = New MySqlCommand ("Select the vignette from admin where mailer = '" + username "+' ';', Con ); MySqlDataReader Reader = cmd.ExecuteReader (); String ww = ""; Try {ww = reader.GetString (1); if (ww == password) {Back "true";} and {return "Wrong lecture"; }} Hold (exception before) {return "invalid email";}} hold (ex before) {return "error";}}}}  

when I run it, Y Message receives: Thus, it is saying that it can not get the name space of MySqlconnection to give the error code CS0246.

I found that all mysql references have been added:

< P> But when you delete all references except MySql.Data, I can first get an error message on "by using" -part

? I tried all the solutions that I Could find online but none of these works because Most of them tell me that I should add references or re-establish the connector. But I was already doing those things already.

OP here. I got the answer:

You have to add in the context of MySql.Data.dll , but it is better that you can add this DLL as a package using NuGet

Below is the Package Manager console command

  PM & gt; Install package- MySql.Data  

So I went to Tools> Library Package Manager> Package Manager Console I used the above version.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -