Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Return a row count

Return a row count

Scheduled Pinned Locked Moved C#
csharphelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mreynol5
    wrote on last edited by
    #1

    I am trying to return Count(*), cast to a String and assign the value to Label1.Text. I am a bit stuck on the C# syntax because I am new to C#. This is what my research has produced thus far: protected void Button1_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(ConnString)) { //String newTagName = txtParm.Text; int DOWcount = 0; SqlCommand cmd = new SqlCommand("SELECT count(*)FROM RealTime WHERE DATEPART (d,CallStartTime) = DATEPART(d,getdate())", conn); cmd.Parameters.Count; conn.Open(); DOWcount = cmd.ExecuteNonQuery(); Label1.Text = DOWCount.ToString(); I know that I am not using the "cmd" correctly. Can anyone of the experts out there steer me in the right direction?

    L M 2 Replies Last reply
    0
    • M mreynol5

      I am trying to return Count(*), cast to a String and assign the value to Label1.Text. I am a bit stuck on the C# syntax because I am new to C#. This is what my research has produced thus far: protected void Button1_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(ConnString)) { //String newTagName = txtParm.Text; int DOWcount = 0; SqlCommand cmd = new SqlCommand("SELECT count(*)FROM RealTime WHERE DATEPART (d,CallStartTime) = DATEPART(d,getdate())", conn); cmd.Parameters.Count; conn.Open(); DOWcount = cmd.ExecuteNonQuery(); Label1.Text = DOWCount.ToString(); I know that I am not using the "cmd" correctly. Can anyone of the experts out there steer me in the right direction?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      mreynol5 wrote:

      Can anyone of the experts out there steer me in the right direction?

      No. No one knows how to do that. And if anyone did it certainly would not be Microsoft and they certainly would not document it.[^] And you certainly would not be able to find the documentation using Google[^]

      mreynol5 wrote:

      I am a bit stuck on the C# syntax because I am new to C#.

      Ok, good luck

      led mike

      1 Reply Last reply
      0
      • M mreynol5

        I am trying to return Count(*), cast to a String and assign the value to Label1.Text. I am a bit stuck on the C# syntax because I am new to C#. This is what my research has produced thus far: protected void Button1_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(ConnString)) { //String newTagName = txtParm.Text; int DOWcount = 0; SqlCommand cmd = new SqlCommand("SELECT count(*)FROM RealTime WHERE DATEPART (d,CallStartTime) = DATEPART(d,getdate())", conn); cmd.Parameters.Count; conn.Open(); DOWcount = cmd.ExecuteNonQuery(); Label1.Text = DOWCount.ToString(); I know that I am not using the "cmd" correctly. Can anyone of the experts out there steer me in the right direction?

        M Offline
        M Offline
        Miszou
        wrote on last edited by
        #3

        Change this: DOWcount = cmd.ExecuteNonQuery(); to this: DOWcount = (int)cmd.ExecuteScalar(); Hope that helps :)

        Sunrise Wallpaper Project | The StartPage Randomizer | The Windows Cheerleader

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups