Vb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BABASON
    New Member
    • May 2007
    • 2

    Vb

    This is my problem, I have written all these codes:

    [CODE=vb]Dim combs As New ADODB.Recordset
    cmbacc.Clear
    combs.Open "select acml_account_nu mber from clientsdatabase ", con
    combs.MoveFirst
    While Not combs.EOF
    cmbacc.AddItem (combs!acml_acc ount_number)
    combs.MoveNext
    Wend
    combs.Close
    End Sub
    Sub cmbacc_click()
    Dim mn As ADODB.Recordset
    'Dim path As String ="\images\pictu re.gif
    mn.Open "Select * from CLIENTSDATABASE where acml_account_nu mber='" & cmbacc & "'", con
    PictureBox1.Pic ture = mn!img_passport _img
    End Sub[/CODE]
    Thus, it gives error when I click the account no in the combo box.

    Pls what can I do?
    Last edited by Killer42; May 25 '07, 02:55 AM. Reason: Added [CODE=vb] tag
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by BABASON
    This is my problem, I have written all these codes:

    [CODE=vb]
    Dim combs As New ADODB.Recordset
    cmbacc.Clear
    combs.Open "select acml_account_nu mber from clientsdatabase ", con
    combs.MoveFirst
    While Not combs.EOF
    cmbacc.AddItem (combs!acml_acc ount_number)
    combs.MoveNext
    Wend
    combs.Close
    End Sub
    Sub cmbacc_click()
    Dim mn As ADODB.Recordset
    'Dim path As String ="\images\pictu re.gif
    mn.Open "Select * from CLIENTSDATABASE where acml_account_nu mber='" & cmbacc & "'", con
    PictureBox1.Pic ture = mn!img_passport _img
    End Sub
    [/CODE]
    Thus, it gives error when I click the account no in the combo box.

    Pls what can I do?
    Please tell us the error or plug the error in search terms here, see what you get, or fetch Google, see what comes up...

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      I think the problem is that mn hasn't been connected to the database. You've just defined it and tried to open it. There's a step missing.

      Um...

      I could be wrong, of course. Database connectivity is a bit of a weak area for me.

      Comment

      • cmrhema
        Contributor
        • Jan 2007
        • 375

        #4
        Originally posted by BABASON
        This is my problem, I have written all these codes:

        [CODE=vb]Dim combs As New ADODB.Recordset
        cmbacc.Clear
        combs.Open "select acml_account_nu mber from clientsdatabase ", con
        combs.MoveFirst
        While Not combs.EOF
        cmbacc.AddItem (combs!acml_acc ount_number)
        combs.MoveNext
        Wend
        combs.Close
        End Sub
        Sub cmbacc_click()
        Dim mn As ADODB.Recordset
        'Dim path As String ="\images\pictu re.gif
        mn.Open "Select * from CLIENTSDATABASE where acml_account_nu mber='" & cmbacc & "'", con
        PictureBox1.Pic ture = mn!img_passport _img
        End Sub[/CODE]
        Thus, it gives error when I click the account no in the combo box.

        Pls what can I do?


        Try out this way


        Code:
        Dim combs As New ADODB.Recordset
        cmbacc.Clear
        combs.Open "select acml_account_number from clientsdatabase", con, adOpenDynamic, adLockOptimistic
        
        If combs.BOF = False Then
                    Do Until combs.EOF = True
                    cmbacc.AddItem (combs!acml_account_number)
                  combs.MoveNext
         Else
        MsgBox "no records"
         End If 
        combs.Close
        End Sub
        
        
        Private Sub cmbacc_click()
        Dim mn As ADODB.Recordset
        'Dim path As String ="\images\picture.gif
        mn.Open "Select * from CLIENTSDATABASE where acml_account_number='" & cmbacc & "'", con, adOpenDynamic, adLockOptimistic
        PictureBox1.Picture = mn!img_passport_img
        End Sub

        Next time onwards Kindly let us know what error do you get and where do you get

        Comment

        Working...