C# with MySQL INSERT parameters

后端 未结 9 1976
-上瘾入骨i
-上瘾入骨i 2020-11-28 10:47

Good day to all, I\'m using Visual C# 2010 and MySQL Version 5.1.48-community. I hope you can help me with this code. I don\'t find it working on me. What am I missing?

9条回答
  •  旧时难觅i
    2020-11-28 11:40

    What I did is like this.

    String person;
    String address;
    person = your value;
    address =your value;
    string connString = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
        MySqlConnection conn = new MySqlConnection(connString);
        conn.Open();
        MySqlCommand comm = conn.CreateCommand();
        comm.CommandText = "INSERT INTO room(person,address) VALUES('"+person+"','"+address+"')";
        comm.ExecuteNonQuery();
        conn.Close();
    

提交回复
热议问题