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. Other Discussions
  3. The Weird and The Wonderful
  4. Code reuse

Code reuse

Scheduled Pinned Locked Moved The Weird and The Wonderful
4 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.
  • Z Offline
    Z Offline
    zlezj
    wrote on last edited by
    #1

    I guess the programmer of the snippet below found a function to fill a DropDownList and adjusted it just enough to fill a TextBox...

    Private Sub ShowName(ByVal id As String)

    Dim daNames As New SqlDataAdapter("SELECT ID, NAME FROM TBL\_NAMES", ConnectionString)
    
    Dim dsNames As New DataSet("NAMES")
    daNames.Fill(dsNames, "NAMES")
    
    Dim drNames As DataRow = dsNames.Tables(0).NewRow
    drNames("ID") = -1
    drNames("NAME") = ""
    
    dsNames.Tables(0).Rows.InsertAt(drNames, 0)
    
    If dsNames.Tables("NAMES").Rows.Count > 0 Then
    	Try
    		Dim drs() As DataRow = dsNames.Tables(0).Select("ID = " & id)
    		txtName.Text = drs(0).Item("NAME").ToString
    	Catch e As Exception
    		'
    	End Try
    Else
    	txtName.Text = ""
    End If
    

    End Sub

    P 1 Reply Last reply
    0
    • Z zlezj

      I guess the programmer of the snippet below found a function to fill a DropDownList and adjusted it just enough to fill a TextBox...

      Private Sub ShowName(ByVal id As String)

      Dim daNames As New SqlDataAdapter("SELECT ID, NAME FROM TBL\_NAMES", ConnectionString)
      
      Dim dsNames As New DataSet("NAMES")
      daNames.Fill(dsNames, "NAMES")
      
      Dim drNames As DataRow = dsNames.Tables(0).NewRow
      drNames("ID") = -1
      drNames("NAME") = ""
      
      dsNames.Tables(0).Rows.InsertAt(drNames, 0)
      
      If dsNames.Tables("NAMES").Rows.Count > 0 Then
      	Try
      		Dim drs() As DataRow = dsNames.Tables(0).Select("ID = " & id)
      		txtName.Text = drs(0).Item("NAME").ToString
      	Catch e As Exception
      		'
      	End Try
      Else
      	txtName.Text = ""
      End If
      

      End Sub

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      DataAdapter and DataSet are so powerful they can be used to do anything... poorly.

      T 1 Reply Last reply
      0
      • P PIEBALDconsult

        DataAdapter and DataSet are so powerful they can be used to do anything... poorly.

        T Offline
        T Offline
        Tristan Rhodes
        wrote on last edited by
        #3

        Cool! Can i quote that? I had a boss who used those as his all powerful silver bullet, and many a wtf ensued.

        ------------------------------- Carrier Bags - 21st Century Tumbleweed.

        P 1 Reply Last reply
        0
        • T Tristan Rhodes

          Cool! Can i quote that? I had a boss who used those as his all powerful silver bullet, and many a wtf ensued.

          ------------------------------- Carrier Bags - 21st Century Tumbleweed.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Ummm yeah.

          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