I am quite new with C#, i have decided to go from PHP to Software Development and has thus far been studying a whole lot of books and tutorials. But this code down here is giving me trouble, please note this is a very basic operation I'm trying to just understand how things work...
Any help would be appreciated.
The following Code does nothing, it does not INSERT a new row into the database. I get the SELECT procedure to work but not this? Any Ideas?
private void button1_Click(object sender, EventArgs e)
FirstName = Convert.ToString(textBox1.Text);
LastName = Convert.ToString(textBox2.Text);
Country = Convert.ToString(textBox3.Text);
//GREATE CONNECTION TO DATABASE
SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLExpress;AttachDbFilename=|DataDirectory|\\DataBaseAccessDb.mdf;Integrated Security=True;User Instance=True;");
SqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = "INSERT INTO Users (FirstName, LastName, Country) VALUES (@FirstName, @LastName, @Country)";
catch (Exception ex)
richTextBox1.Text = "There was an Error: " + Convert.ToString(ex);