title: saving multiple data grid view value to database
body: <p>I have some rows in data grid view . I want to save them together in database..Please help me to do that. Thanks in Advance . I wrote the following but it doesn't work....!!!</p>
  
  <pre><code>private void btnSave_Click(object sender, EventArgs e)
          {
              string StrQuery;
              try
              {
                  using (SqlCommand comm = new SqlCommand())
                  {
                      comm.Connection = myConnection;
                      myConnection.Open();
                      for (int i = 0; i &lt; addcrsView.Rows.Count; i++)
                      {
                          StrQuery = @"INSERT INTO student_reg VALUES (" + id + ","
                              + addcrsView.Rows[i].Cells["Course Name"].Value + ", "
                              + addcrsView.Rows[i].Cells["Credit"].Value + ");";
                         comm.CommandText = StrQuery;
                         if (comm.ExecuteNonQuery() &gt; 0)
                         {
                             MessageBox.Show("inserted");
                         }
                         else
                         {
                             MessageBox.Show("Not insert");
                         }
  
                      }
                  }
  
              }
              catch
              {
                  MessageBox.Show("Catch");
              }
          }
  </code></pre>