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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

insert statement into mysql with asp.net

  • 18-11-2006 3:15pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 872 ✭✭✭grahamor


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


Advertisement