Multi-row Textbox Data Binding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sekshin8
    New Member
    • Apr 2007
    • 4

    Multi-row Textbox Data Binding

    I am trying to bind fields from the first three records of a query (three records will always be returned by the query) to three textboxes on a windows form.

    ex.
    Textbox1.text = row1 column1
    Textbox2.text = row2 column1
    Textbox3.text = row3 column1

    another three textboxes would contain the values from the second column
    Textbox4.text = row1 column2
    Textbox5.text = row2 column2
    Textbox6.text = row3 column2

    I tried creating three binding sources and using filters but that didnt work and I can't use a datagrid. I was hoping to do this without creating multiple adapters or connections etc.. Any suggestions?
  • Casey
    New Member
    • Aug 2006
    • 8

    #2
    Can you create a datareader from the query and loop through it?

    Dim x as Integer = 1
    Dim dbConnect as your database connection
    dim sqlCommand as your query, dbConnect
    Dim dtrStuff as Datareader = sqlCommand .ExecuteReader( )

    While Not dtrStuff .EOF
    if x = 1 then textbox1.text = dtrStuff ("column")
    if x = 2 then textbox2 .text= dtrStuff ("column")
    if x = 3 then textbox3.text = dtrStuff ("column")
    x = x + 1
    Next

    The exact syntax, of course, you'll need to work out. But the idea should work.

    Casey

    Comment

    • sekshin8
      New Member
      • Apr 2007
      • 4

      #3
      Thanks for your response but your suggestion isn't exactly what I am looking for since the data isn't bound to the textbox.


      Originally posted by Casey
      Can you create a datareader from the query and loop through it?

      Dim x as Integer = 1
      Dim dbConnect as your database connection
      dim sqlCommand as your query, dbConnect
      Dim dtrStuff as Datareader = sqlCommand .ExecuteReader( )

      While Not dtrStuff .EOF
      if x = 1 then textbox1.text = dtrStuff ("column")
      if x = 2 then textbox2 .text= dtrStuff ("column")
      if x = 3 then textbox3.text = dtrStuff ("column")
      x = x + 1
      Next

      The exact syntax, of course, you'll need to work out. But the idea should work.

      Casey

      Comment

      • sekshin8
        New Member
        • Apr 2007
        • 4

        #4
        Anyone else?

        Comment

        Working...