So I'm building this asp website for my school project. I'm using Visual Studio 2010-C# for the development and MySql for Database. I attached SqlDataSource from Tools and it gave me a connectionString in Web.config and it like goes like this:
<connectionStrings>
<add name="webServerConnectionString" connectionString="user id=root;password=root;persistsecurityinfo=True;server=127.0.0.1;database=webServer" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
Now, I'm having trouble to what I should write inside the Register.aspx if I want to use that connection and input data to database. This is what I formulated at the moment. I think its incomplete, I just don't know what to add. I already added MySql.data in References.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
using System.Configuration;
namespace hproj
{
public partial class Register1 : System.Web.UI.Page
{
MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void regcreate_Click(object sender, EventArgs e)
{
MySqlCommand cmd = new MySqlCommand("INSERT INTO login(userid, user_pass, email) VALUES ('"+reguname+"','"+regpword+"','"+regemail+"')", con);
cmd.ExecuteNonQuery();
con.Close();
reglabel.Visible = true;
reglabel.Text = "Account Creation Successful";
reguname.Text = "";
regpword.Text = "";
regconfirmpword.Text = "";
regemail.Text = "";
}
}
This string gives me the error even though I have full permission and authority in MySql Workbench:
Host 'Han-PC' is not allowed to connect to this MySQL server