title: Execute two sql commands related in VB.NET
body: <p>I'm trying to execute two related sql commands in a single function top update my column xamlfile by a new xamlfile --> u</p>
  
  <p>Here's my code</p>
  
  <pre><code>Public Shared Function updatetest()
  
      Dim c As SqlConnection = openConnection("Data Source=GENIOP40;Initial Catalog=TF5100_new;Integrated Security=true")
      Dim c2 As SqlConnection = openConnection("Data Source=GENIOP40;Initial Catalog=TF5100_new;Integrated Security=true")
      Dim cmd As New SqlCommand("SELECT xamlfile, id_wkfw_task from WKFW_Tasks Where xamlfile like '%ExecuteTask%' order by name", c)
      Dim rd As SqlDataReader = executereader(cmd)
      Dim listxaml As New List(Of String)
      While rd.Read
          Dim u As String = GetString(rd, "xamlfile")
          Dim Id As Guid = GetGuid(rd, "id_wkfw_task")
  
          u = Regex.Replace(u, "(?&lt;=&lt;t[1-2]|:ExecuteTask[^&gt;&lt;]+)\bTache", "TaskID")
  
          u = u.Replace("'", "''")
  
          Dim cmd2 As New SqlCommand("UPDATE WKFW_Tasks set xamlfile=@xmlfile where id_wkfw_task=@id_t", c2)
          cmd2.Parameters.Add("xmlfile", SqlDbType.NVarChar).Value = u
          cmd2.Parameters.Add("id_t", SqlDbType.UniqueIdentifier).Value = Id
          cmd2.CommandTimeout = 0
          executeNonQuery(cmd2)
          c2.Close()
  
      End While
      rd.Close()
      c.Close()
  
  
  End Function
  </code></pre>
  
  <p>My problem is : when I close the reader after the loop, my first command is no more executed, and I need it to be executed so my second command can work, and if I don't close my reader I have an error, any suggestions please ?</p>