Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

ASPNETCORE2.0 MYSQL CONNECTION PROBLEM -- please help.

$
0
0

Hello.. I'm working on an ASP net core 2.0 mvc 5 Project and I'm having problems on trying to connect to an online mysql database.

I Will share all the information I get from the website that provides free database hosting service, becouse they r not precious anyways, and just for testing...

I will be really thankfull if someone could help me... I'm running out of time and I'm yet to start the project.

Thank you already.

------------------------------------

Your account number is: 288396

Your new database is now ready to use.

To connect to your database use these details

Server: sql7.freemysqlhosting.net
Name: sql7238434
Username: sql7238434
Password: 4qjcgJuxxU
Port number: 3306

appsettings.json

"ConnectionStrings": {

"DefaultConnection": "server=sql7.freemysqlhosting.net;port=3306;database=sql7238434;uid=sql7238434;password=4qjcgJuxxU"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": { "Default": "Warning" }
}
}

CONTEXT.CS

public class HerseyinContext
{
public string ConnectionString { get; set; }
public HerseyinContext(string connetionString)
{
this.ConnectionString = ConnectionString;

}
private MySqlConnection GetConnection()
{
return new MySqlConnection(ConnectionString);
}


public List<Users> GetAllUsers()
{
List<Users> list = new List<Users>();
using (MySqlConnection conn = GetConnection())
{
conn.Open(); ---------HERE I GET THE ERORR! -->MySql.Data.MySqlClient.MySqlException: 'Host 'ASUS' is not allowed to connect to this MariaDB server'
MySqlCommand cmd = new MySqlCommand("select * from Users", conn);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{

list.Add(new Users()
{
ID = Convert.ToInt32(reader["ID"]),
USERNAME = reader["USERNAME"].ToString(),
PASSWORD = reader["PASSSWORD"].ToString()
});


}
}
return list;
}
}


}


Viewing all articles
Browse latest Browse all 1350

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>