Problem with my codes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deena22
    New Member
    • Nov 2006
    • 8

    #1

    Problem with my codes

    hello,

    i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet '. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have got 2 textboxes into which the user will enter the 'Start date' and in the other textbox, the user will enter the 'End date'. The system i'm developing should then find the total number of hours worked from the 'start date' to the 'end date' for the item selected in the 'type of staff' List Box and for the item selected in the 'name of project' List Box. For example, if i choose 'engineer' in the first List Box, i choose 'project aaa' in my second List Box, i enter '4/5/06' as 'Start date' and '10/9/06' as 'End Date', then when the user click on the button ''Calculate Hours Worked '' the 'sum of the hours worked' by the 'engineer' on 'project aaa' from '4/5/06' to '10/9/06' should be calculated and be displayed in a textbox.

    I have been using 'ADODC' to connect my 'List Boxes' and the 'Start' and 'End Date' Text Boxes to the database through the 'DataSource' and 'DataField'. In the 'Provider' tab of the 'Data Link Properties' of the 'ADODC', i have selected ''Microsoft Jet 3.51 OLE DB Provider.Is it good?

    Also i have inserted the following codes :

    Command1_Click( )
    Dim con As New ADODB.Connectio n
    Dim con_string As String
    Dim sql As String
    Dim rs As New ADODB.Recordset
    con_string = ''Provider = Microsoft.Jet.O LEDB.3.51; Data Source = '' & App.Path & '' \ '' & ''timesheet.mdb ; ''
    con.Open con_string
    While Not rs.EOF
    If rs(1) = List1.List(List 1.ListIndex) And rs(3) = List2.List(List 2.ListIndex) And CDate(rs(2)) >= CDate(Text1.Tex t) And CDate(rs(2)) <= CDate(Text2.Tex t)
    Then
    hoursworked = hoursworked + rs(5)
    End If
    rs.Movenext
    Wend
    Text3.Text = hoursworked

    But when i run the program, then the error message that i got is the following:

    Run-time error '3706'
    Provider cannot be found. It may not be properly installed.
    When i click on debug button, then it indicates the following as bug:
    con.Open con_string

    What is the solution to my problem?

    Also, when i run the program, without me entering the dates, the first date in my database is displayed in my 'Start and End Date' , which should not have been the case. How do i prevent this?

    What is the solution to my problem?

    Thanks
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Originally posted by deena22
    hello,

    i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet '. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have got 2 textboxes into which the user will enter the 'Start date' and in the other textbox, the user will enter the 'End date'. The system i'm developing should then find the total number of hours worked from the 'start date' to the 'end date' for the item selected in the 'type of staff' List Box and for the item selected in the 'name of project' List Box. For example, if i choose 'engineer' in the first List Box, i choose 'project aaa' in my second List Box, i enter '4/5/06' as 'Start date' and '10/9/06' as 'End Date', then when the user click on the button ''Calculate Hours Worked '' the 'sum of the hours worked' by the 'engineer' on 'project aaa' from '4/5/06' to '10/9/06' should be calculated and be displayed in a textbox.

    I have been using 'ADODC' to connect my 'List Boxes' and the 'Start' and 'End Date' Text Boxes to the database through the 'DataSource' and 'DataField'. In the 'Provider' tab of the 'Data Link Properties' of the 'ADODC', i have selected ''Microsoft Jet 3.51 OLE DB Provider.Is it good?

    Also i have inserted the following codes :

    Command1_Click( )
    Dim con As New ADODB.Connectio n
    Dim con_string As String
    Dim sql As String
    Dim rs As New ADODB.Recordset
    con_string = ''Provider = Microsoft.Jet.O LEDB.3.51; Data Source = '' & App.Path & '' \ '' & ''timesheet.mdb ; ''
    con.Open con_string
    While Not rs.EOF
    If rs(1) = List1.List(List 1.ListIndex) And rs(3) = List2.List(List 2.ListIndex) And CDate(rs(2)) >= CDate(Text1.Tex t) And CDate(rs(2)) <= CDate(Text2.Tex t)
    Then
    hoursworked = hoursworked + rs(5)
    End If
    rs.Movenext
    Wend
    Text3.Text = hoursworked

    But when i run the program, then the error message that i got is the following:

    Run-time error '3706'
    Provider cannot be found. It may not be properly installed.
    When i click on debug button, then it indicates the following as bug:
    con.Open con_string

    What is the solution to my problem?

    Also, when i run the program, without me entering the dates, the first date in my database is displayed in my 'Start and End Date' , which should not have been the case. How do i prevent this?

    What is the solution to my problem?

    Thanks
    Hi there,

    Which version of MSAccess are you working on? If you are on Access 200 then you should change the OLE DB Provider to 4.0, hope it helps. Good luck & Take care.

    Comment

    • rockford333
      New Member
      • Sep 2006
      • 15

      #3
      Originally posted by deena22
      hello,

      i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet '. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have got 2 textboxes into which the user will enter the 'Start date' and in the other textbox, the user will enter the 'End date'. The system i'm developing should then find the total number of hours worked from the 'start date' to the 'end date' for the item selected in the 'type of staff' List Box and for the item selected in the 'name of project' List Box. For example, if i choose 'engineer' in the first List Box, i choose 'project aaa' in my second List Box, i enter '4/5/06' as 'Start date' and '10/9/06' as 'End Date', then when the user click on the button ''Calculate Hours Worked '' the 'sum of the hours worked' by the 'engineer' on 'project aaa' from '4/5/06' to '10/9/06' should be calculated and be displayed in a textbox.

      I have been using 'ADODC' to connect my 'List Boxes' and the 'Start' and 'End Date' Text Boxes to the database through the 'DataSource' and 'DataField'. In the 'Provider' tab of the 'Data Link Properties' of the 'ADODC', i have selected ''Microsoft Jet 3.51 OLE DB Provider.Is it good?

      Also i have inserted the following codes :

      Command1_Click( )
      Dim con As New ADODB.Connectio n
      Dim con_string As String
      Dim sql As String
      Dim rs As New ADODB.Recordset
      con_string = ''Provider = Microsoft.Jet.O LEDB.3.51; Data Source = '' & App.Path & '' \ '' & ''timesheet.mdb ; ''
      con.Open con_string
      While Not rs.EOF
      If rs(1) = List1.List(List 1.ListIndex) And rs(3) = List2.List(List 2.ListIndex) And CDate(rs(2)) >= CDate(Text1.Tex t) And CDate(rs(2)) <= CDate(Text2.Tex t)
      Then
      hoursworked = hoursworked + rs(5)
      End If
      rs.Movenext
      Wend
      Text3.Text = hoursworked

      But when i run the program, then the error message that i got is the following:

      Run-time error '3706'
      Provider cannot be found. It may not be properly installed.
      When i click on debug button, then it indicates the following as bug:
      con.Open con_string

      What is the solution to my problem?

      Also, when i run the program, without me entering the dates, the first date in my database is displayed in my 'Start and End Date' , which should not have been the case. How do i prevent this?

      What is the solution to my problem?

      Thanks

      Have u solve the problem, if not u send me the email to my address to rockford333@gma il.com, with subject con problem.

      Comment

      • vatsgauravchauhan
        New Member
        • Nov 2006
        • 3

        #4
        Originally posted by deena22
        hello,

        i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet '. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have got 2 textboxes into which the user will enter the 'Start date' and in the other textbox, the user will enter the 'End date'. The system i'm developing should then find the total number of hours worked from the 'start date' to the 'end date' for the item selected in the 'type of staff' List Box and for the item selected in the 'name of project' List Box. For example, if i choose 'engineer' in the first List Box, i choose 'project aaa' in my second List Box, i enter '4/5/06' as 'Start date' and '10/9/06' as 'End Date', then when the user click on the button ''Calculate Hours Worked '' the 'sum of the hours worked' by the 'engineer' on 'project aaa' from '4/5/06' to '10/9/06' should be calculated and be displayed in a textbox.

        I have been using 'ADODC' to connect my 'List Boxes' and the 'Start' and 'End Date' Text Boxes to the database through the 'DataSource' and 'DataField'. In the 'Provider' tab of the 'Data Link Properties' of the 'ADODC', i have selected ''Microsoft Jet 3.51 OLE DB Provider.Is it good?

        Also i have inserted the following codes :

        Command1_Click( )
        Dim con As New ADODB.Connectio n
        Dim con_string As String
        Dim sql As String
        Dim rs As New ADODB.Recordset
        con_string = ''Provider = Microsoft.Jet.O LEDB.3.51; Data Source = '' & App.Path & '' \ '' & ''timesheet.mdb ; ''
        con.Open con_string
        While Not rs.EOF
        If rs(1) = List1.List(List 1.ListIndex) And rs(3) = List2.List(List 2.ListIndex) And CDate(rs(2)) >= CDate(Text1.Tex t) And CDate(rs(2)) <= CDate(Text2.Tex t)
        Then
        hoursworked = hoursworked + rs(5)
        End If
        rs.Movenext
        Wend
        Text3.Text = hoursworked

        But when i run the program, then the error message that i got is the following:

        Run-time error '3706'
        Provider cannot be found. It may not be properly installed.
        When i click on debug button, then it indicates the following as bug:
        con.Open con_string

        What is the solution to my problem?

        Also, when i run the program, without me entering the dates, the first date in my database is displayed in my 'Start and End Date' , which should not have been the case. How do i prevent this?

        What is the solution to my problem?

        Thanks
        Hi there,
        first check the version of ur Access. If u r working on 2000 use OLEDB.4.0. else

        use this kind of connection
        command1_click( )
        dim con as connection
        dim rs as recordset

        set con=new adodb.connectio n
        with con
        .provider="Micr osoft.Jet.OLEDB .3.51"
        .connectionstri ng="uid=;pwd=;d ata source=" & App.path & "\" & "timesheet.mdb; "
        .open
        end with

        hope this will solve ur problem

        Comment

        Working...