Results 1 to 8 of 8

Thread: VB6 to VB.Net - "Control.DataSource"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210

    VB6 to VB.Net - "Control.DataSource"

    in vb6 i have this working:
    VB Code:
    1. rsvar.Open "select * from clients", cn, adOpenKeyset, adLockOptimistic
    2.     For Each Control In cad_clientes.Controls
    3.     If TypeOf Control Is TextBox Then
    4.         Set Control.DataSource = rsvar
    5.     End If
    6.     Next Control

    how can i do the same thing in VB.Net??

    Thank you,
    Guilherme

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Is cad_clientes the name of the form ? if yes , then just replace it with Me keyword .

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210
    this code:
    VB Code:
    1. rsvar.Open("select * from clientes where fornecedor = 'f' order by nome", cn, adOpenKeyset, adLockOptimistic)
    2.  
    3.         For Each Control In Me.Controls
    4.  
    5.             If TypeOf Control Is TextBox Then
    6.                 Control.DataSource = rsvar
    7.             End If
    8.  
    9.         Next Control

    works, but the "Control" word the vb.net doesn´t found!!

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Put this at the first line of the above code :
    VB Code:
    1. Dim Control As Control

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Or if you have VS 2003:
    VB Code:
    1. rsvar.Open("select * from clientes where fornecedor = 'f' order by nome", cn, adOpenKeyset, adLockOptimistic)
    2.  
    3.         For Each ctrl As Control In Me.Controls
    4.             If TypeOf Control Is TextBox Then
    5.                 ctrl.DataSource = rsvar
    6.             End If
    7.         Next




    Although the bigger question is why are you using the old ADO instead of ADO.NET?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210
    and how i use ADO.NET?
    is there a lot of diference??
    it´s better or faster??

    i use to program VB6 and Java. I am starting with VB.Net, so probably, i will do a lot code in the wrong way, i mean, i will program not like the thinkers of VB.net excpet we do!!

    Thanks a lot,
    Guilherme

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Definitely you need a book or some tutorials . Search the forum for some million of links on this issue ...lol

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You might try reading the ADO.NEt section here: http://samples.gotdotnet.com/quickstart/howto/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width