I have this code when i run it after i add the values in the textbox its suppose to insert the values from the textbox into the database but its not doing it.. i don't know why its not here. I don't get no error message or anything..
System.Data.SqlClient.SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString =
@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDiary.mdf;Integrated Security=True;User Instance=True";
System.Data.SqlClient.SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
//tell the compiler and database that we're using parameters (thus the @first, @last, @nick)
dataCommand.CommandText = ("INSERT INTO UserProfile (Fname,Lname,UserName,Email,Pword,RePword) VALUES (@first,@last,@User,@Myemail,@MyPword,@MyRePword)");
//add our parameters to our command object
dataCommand.Parameters.AddWithValue("@first", first);
dataCommand.Parameters.AddWithValue("@last", last);
dataCommand.Parameters.AddWithValue("@User", User);
dataCommand.Parameters.AddWithValue("@MyPword", MyPword);
dataCommand.Parameters.AddWithValue("@Myemail", Myemail);
dataCommand.Parameters.AddWithValue("@MyRePword", MyRePword);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
dataConnection.Close();
<Will The Great>
System.Data.SqlClient.SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString =
@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDiary.mdf;Integrated Security=True;User Instance=True";
System.Data.SqlClient.SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
//tell the compiler and database that we're using parameters (thus the @first, @last, @nick)
dataCommand.CommandText = ("INSERT INTO UserProfile (Fname,Lname,UserName,Email,Pword,RePword) VALUES (@first,@last,@User,@Myemail,@MyPword,@MyRePword)");
//add our parameters to our command object
dataCommand.Parameters.AddWithValue("@first", first);
dataCommand.Parameters.AddWithValue("@last", last);
dataCommand.Parameters.AddWithValue("@User", User);
dataCommand.Parameters.AddWithValue("@MyPword", MyPword);
dataCommand.Parameters.AddWithValue("@Myemail", Myemail);
dataCommand.Parameters.AddWithValue("@MyRePword", MyRePword);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
dataConnection.Close();
<Will The Great>