Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

insert statement into mysql with asp.net

Options
  • 18-11-2006 4:15pm
    #1
    Registered Users Posts: 872 ✭✭✭


    im having trouble inserting form values into a mySQL database

    Im can insert the following static statement no problem

    string sql = "INSERT INTO mailinglist (name,email) VALUES('my name','my email')";

    MySqlCommand cmd = new MySqlCommand(sql, conn)

    but i need to do this with form values and i thought i'd just be able to add variable values to the end of the SQL string but it's throwing errors.

    string sql = "INSERT INTO mailinglist (name,email) VALUES("+name.Text+","+email.Text+")";

    Any ideas ? ( it's probably simple). Can i use parameters ?

    Thanks


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    What are the errors that you're getting?

    Though I can spot one thing straight off - you're not using any quotes when inserting text values, e.g.

    string sql = "INSERT INTO mailinglist (name,email) VALUES('"+name.Text+"','"+email.Text+"')";


  • Registered Users Posts: 872 ✭✭✭grahamor


    that seems to have solved it Seamus, thanks for the help.


Advertisement