0

I have another class that creates the connection (see refined class half way down page) and I believe it connects or at lest I do not hit any of the exceptions in run time.

I would now like to insert data into my database but nothing is updated. I am trying to follow this example but it is for reading.

I did run "querystring" on the show SQL Pane and it does execute correctly. It inserts data properly as a new row.

not sure what to do after my last line? Thanks.

string queryString =
"INSERT INTO UserData UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES ('a051fc1b-4f51-485b-a07d-0f378528974e', 2, 2, 2);";

    protected void Button1_Click(object sender, EventArgs e)
    {
        MySqlConnection database = new MySqlConnection();
        database.CreateConn();

        Command = new SqlCommand(queryString, database.Connection);  //

    }

1 Answer 1

4
 Command.ExecuteNonQuery();

By the way, you're missing a parenthesis in your SQL query string.

And of course, you'd use parameters in a real query (and you will not use string concatenation instead of passing parameters as it'll open doors for destructive SQL injection attacks).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.