Insert Into MySql Table

Mar 27 2012 9:19 AM
Im sorry if you have seen this question a thousand times, But ive googled this and still couldnt find a solution. I googled and changed my code a bit but it still doesnt fix my code.

So,i want insert data into my Mysql table But it kept giving me errors, the lastest of which is "Only MySqlParamaters objects may be stored", 

Here is my Code:

MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["MySql"].ConnectionString);

string com = "INSERT INTO Users(Name, Surname, Pass, Email, Type)
VALUES(@Name,@Surname,@Password,@Emailaddr, @type)";

MySqlCommand Com = new MySqlCommand(com, con);

Com.CommandType = CommandType.Text;
Com.Parameters.Add(new MySqlParameter("?Name", MySqlDbType.Text).Value = txtfname.Text);
Com.Parameters.Add(new MySqlParameter("?Surname", MySqlDbType.Text).Value = txtlname.Text);
Com.Parameters.Add(new MySqlParameter("?Password", MySqlDbType.Text).Value = txtpass11.Text);
Com.Parameters.Add(new MySqlParameter("?Emailaddr", MySqlDbType.Text).Value = txtemail.Text);
Com.Parameters.Add(new MySqlParameter("?type", MySqlDbType.Text).Value = "Patient");

con.Open();
Com.ExecuteNonQuery();

con.Close();




Answers (1)