-
March 27th, 2012, 08:46 AM
#1
Insert into MySql Table
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 from an asp.net page 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();
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|