Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Talk:DataReader

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
Latest comment: 13 years ago by 5.10.169.18 in topic Sample code suggestion

Sample code suggestion

[edit]

I suggest the following example (please note the additional using for mycommand and avoiding string concatenation):

void DataTest()
{
  using (SqlConnection conn1 = new SqlConnection(...))
  {
    conn1.Open();

    using (SqlCommand mycommand = new SqlCommand("Select * From someTable", conn1))
    using (SqlDataReader myreader = mycommand.ExecuteReader())
    {
      if(myreader == null)
      {
        return;
      }

      while(myreader.Read())
      {
        Console.WriteLine(string.Format("{0}:{1}", myreader.GetValue(0), myreader.GetTypeName(0));
      }
    }
  }
}

What do other's think? --Blue4k (talk) 17:49, 23 December 2010 (UTC)Reply

I like it! Much clearer! Wikipedia:Be bold 5.10.169.18 (talk) 14:36, 6 February 2013 (UTC)Reply