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. Database & SysAdmin
  3. Database
  4. Populate label from SQL query...

Populate label from SQL query...

Scheduled Pinned Locked Moved Database
databasecsharpasp-nethelp
3 Posts 2 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.
  • J Offline
    J Offline
    japel
    wrote on last edited by
    #1

    Hi All Very new to SQL and ASP.Net but need to populate a lable from a SQL query. Dim sqlDbAdapter1 As New Data.SqlClient.SqlDataAdapter("SELECT COUNT(*) AS myCount FROM dbo.IssueTb ", sqlconn) sqlDbAdapter.Fill(sqlDataset, "IssueTb") Dim Issuedv As DataView = sqlDataset.Tables("IssueTb").DefaultView The above loads a Dataset and DataView with the value but I don't know to bind to the label on the web page. Databinding used on vb.net was my first try but this was wrong so could someone please help. Thanks Heaps...

    When people make you see red, be thankful your not colour blind.

    C 1 Reply Last reply
    0
    • J japel

      Hi All Very new to SQL and ASP.Net but need to populate a lable from a SQL query. Dim sqlDbAdapter1 As New Data.SqlClient.SqlDataAdapter("SELECT COUNT(*) AS myCount FROM dbo.IssueTb ", sqlconn) sqlDbAdapter.Fill(sqlDataset, "IssueTb") Dim Issuedv As DataView = sqlDataset.Tables("IssueTb").DefaultView The above loads a Dataset and DataView with the value but I don't know to bind to the label on the web page. Databinding used on vb.net was my first try but this was wrong so could someone please help. Thanks Heaps...

      When people make you see red, be thankful your not colour blind.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Because you are only returning one column in one row you would be better off without the Data Adapter Dim cmd AS New SqlCommand() cmd.CommandText = "SELECT COUNT(*) FROM dbo.IssueTb" cmd.Connection = sqlConn Dim result As Int32 result = cmd.ExecuteScalar() ... SomeLabel.Text = result.ToString()


      Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      J 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Because you are only returning one column in one row you would be better off without the Data Adapter Dim cmd AS New SqlCommand() cmd.CommandText = "SELECT COUNT(*) FROM dbo.IssueTb" cmd.Connection = sqlConn Dim result As Int32 result = cmd.ExecuteScalar() ... SomeLabel.Text = result.ToString()


        Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

        J Offline
        J Offline
        japel
        wrote on last edited by
        #3

        Thanks Heaps This worked out great...

        When people make you see red, be thankful your not colour blind.

        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