So apparently, ExecuteReader is used for read only and ExecuteNonQuery is used for transactions. But for some reason even when I used ExecuteReader I am still able to run write (Insert, Update, Delete) commands (typed in textbox1). Is there something wrong with my code or am I misunderstanding the way ExecuteReader is supposed to work?
//MY CODE
string sqlStatement = textbox1.Text;
System.Data.SqlClient.SqlConnectionStringBuilder builder =
new System.Data.SqlClient.SqlConnectionStringBuilder();
builder.DataSource = ActiveServer;
builder.IntegratedSecurity = true;
System.Data.SqlClient.SqlConnection Connection = new
System.Data.SqlClient.SqlConnection(builder.ConnectionString);
Connection.Open();
System.Data.SqlClient.SqlCommand command = new
System.Data.SqlClient.SqlCommand(sqlStatement, Connection);
System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader();
dataGridView1.AutoGenerateColumns = true;
bindingSource1.DataSource = reader;
dataGridView1.DataSource = bindingSource1;
reader.Close();
Connection.Close();