Results 1 to 3 of 3

Thread: convert this simple vb6 app to vb.net?

  1. #1

    Thread Starter
    New Member callisto's Avatar
    Join Date
    Mar 2003
    Posts
    14

    convert this simple vb6 app to vb.net?

    VB Code:
    1. Option Explicit
    2. Dim cn As New ADODB.Connection  
    3. Dim rs As New ADODB.Recordset    
    4. Private Sub cmdConnect_Click()    
    5.     cn.ConnectionString = "DRIVER={SQL SERVER};SERVER=192.168.0.1;DATABASE=dev_test;UID=sa;PWD=password;"    
    6.     cn.Open    
    7.      rs.Open "Select * from Brokerdb", cn, adOpenStatic, adLockOptimistic  
    8. End Sub    
    9.  
    10. Private Sub cmdMoveNext_Click()    
    11.    If (Not rs.EOF) Then        
    12.      Text1.Text = rs.Fields(0)      
    13.      Text2.Text = rs.Fields(1)        
    14.      rs.MoveNext    
    15.    End If  
    16. End Sub  
    17.  
    18. Private Sub cmdMovePrevious_Click()    
    19.   If (Not rs.BOF) Then        
    20.    Text1.Text = rs.Fields(0)      
    21.    Text2.Text = rs.Fields(1)        
    22.    rs.MovePrevious    
    23.   End If  
    24.  
    25. End Sub

    I'm trying to move to .Net. Have trouble with gettting certain fields out of the the data returned from the database.
    Example: Select * from BrokerDB returns the following fields - BrokerName, BrokerCode, BrokerLocation.
    How do I get the 3rd row, BrokerName and BrokerLocation into 2 textboxes?
    Or add rows 2 through 10, Fields BrokerName and BrokerLocation into 2 Listboxes (one for BrokerLocation) and other for BrokerName)?
    I've 3 yrs VB6 experience, 3 day .NET.
    Last edited by callisto; May 11th, 2004 at 04:01 AM.
    If life throws you a curve,
    code a parabole.

  2. #2
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    Bind the textboxes to field then use bindingcontext to move the records .. or try to use dataform wizard then follow the codes .. (it uses binding context) .. good luck


    Winanjaya

  3. #3

    Thread Starter
    New Member callisto's Avatar
    Join Date
    Mar 2003
    Posts
    14
    Thanx Winyanya for replying.

    I do not want to Bind the constituent controls at all! Want to set text/caption property to dataset field value manually. This is preparation for moving a BIG VB6 app to .Net.

    I'll fight the dragon until I win!!!
    If life throws you a curve,
    code a parabole.

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