Results 1 to 14 of 14

Thread: Cannot interact with Access database [Resolved]

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163

    Question Cannot interact with Access database [Resolved]

    P/S: Please refer to the attachment for the error message that pops up!

    My situation and problems:
    I created an Installer for my VB.NET project. This program interacts with a database in Microsoft Access format. I built this program on Windows XP Professional Edition with Microsoft Visual Studio .NET.

    At first, I installed Microsoft .NET Framework 1.1. When I install this program using the Installer on a Windows XP Home Edition PC, it works fine but cannot interacts with the database. Please refer to the attachment for the error message that pops up.

    This PC does not has Microsoft Access. So I installed Microsoft Data Access Components 2.7 SP1. I tought it will works fine but it still cannot interacts with the database.

    So I installed Microsoft Access XP. This also did not solved the problem.

    For your information, this PC is a new one, with only the following softwares installed:
    Windows XP Home Edition
    Windows .NET Framework 1.1
    Windows Data Access Componenets 2.7 SP1
    Microsoft Access XP

    Question 1:
    How can I solve this problem? Is there any software that I need to installed for my program to interact with the Access database?

    Question 2:
    What is the purpose of Microsoft Data Access Components? Is it used to interact with Access database file without installing Microsoft Access?

    Question 3:
    If my program will to interact with Microsoft Access database file, does the PC that runs this program must have Microsoft Access installed? Is there any alternative?

    I'm looking forward for answers of my questions. Please guide me. Thank you!

    P/S: Please refer to the attachment for the error message that pops up!
    Attached Images Attached Images  
    Last edited by albertlse; Aug 21st, 2003 at 08:20 PM.

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Is the DB on the same PC with the program or is the DB on another PC on the network?

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Whats the code on and around line 297 of frmPrintReport?

  4. #4

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163

    Question

    The database is on the same PC.

    Line 297 is inside the following function:
    Code:
    Private Sub subFillcboReportCode()
            Try
                'Open database connection
                ReportConnection.Open()
    
                'Clear ReportDataSet from last operation
                ReportDataSet.Tables.Clear()
    
                'Create SQL query to find Client Listing Code / Invoice Number
                ReportDataAdapter.SelectCommand.CommandText = _
                    "SELECT " & strReportType & " " & _
                    "FROM " & strDatabaseTable & " " & _
                    "WHERE " & strDatabaseTable & "Date LIKE " & Chr(34) & strReportDate & Chr(34) & " " & _
                    "ORDER BY " & strReportType
    
                'Fill ReportDataSet with rows resulting from query
                ReportDataAdapter.Fill(ReportDataSet)
    
                'Add ReportDataSet to cboReportCodeFrom & cboReportCodeTo
                'Set dataTable
                Dim dataTable As DataTable = ReportDataSet.Tables(0)
    
                'Ensure dataTable not empty
                If dataTable.Rows.Count <> 0 Then
                    'Retrieve total row in dataTable
                    Dim intTotalRow As Integer = dataTable.Rows.Count
    
                    'Clear items in cboReportCodeFrom & cboReportCodeTo
                    cboReportCodeFrom.Items.Clear()
                    cboReportCodeTo.Items.Clear()
    
                    'Add entries into cboReportCodeFrom & cboReportCodeTo
                    Dim intCounter As Integer
                    For intCounter = 0 To intTotalRow - 1
                        cboReportCodeFrom.Items.Add( _
                                Convert.ToString(dataTable.Rows(intCounter)(0)) _
                                )
    
                        cboReportCodeTo.Items.Add( _
                            Convert.ToString(dataTable.Rows(intCounter)(0)) _
                            )
                    Next
    
                Else
                    'Clear items in cboReportCodeFrom & cboReportCodeTo
                    cboReportCodeFrom.Items.Clear()
                    cboReportCodeTo.Items.Clear()
                End If
    
                'Close database connection
                ReportConnection.Close()
    
                'Display verbose information with database exception
            Catch oleDbExceptionParameter As System.Data.OleDb.OleDbException
                MessageBox.Show(oleDbExceptionParameter.ToString, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
    
                'Display message box when invalid operation
            Catch invalidOperationExceptionParameter As InvalidOperationException
                MessageBox.Show(invalidOperationExceptionParameter.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub
    when I run this program in my PC which I used to develop it, all fine, no problem / error.

    but when I installed it on the new PC, then got this error.

    please guide me. thank you.

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Are you sure the connection string is correct? Any paths change or anything moving to the new pc? Which line is 297? The Fill method?

  6. #6

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163
    Everything is correct.

    Line 297 is:
    Code:
    ReportDataAdapter.Fill(ReportDataSet)
    Let me make myself clear again:

    I developed this program "Invoice System" on PC-A. Everything is fine. I also created an Installer for this program.

    I used the Installer to install "Invoice System" on PC-B. PC-B is a new PC, only has Windows XP Home Edition, Microsoft Access. After installing "Invoice System", I can open the program. But, it cannot interact with the database. Why? The error message is attachment on my 1st posting, please check it out.

    Am I clear? How can I solve this problem? It seems like, for example, Microsoft developed Office, and works well on their PC. But when I install Office on my PC, then got problem...

    Hope u guys can help me. Thank you.
    Last edited by albertlse; Jul 9th, 2003 at 03:19 AM.

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You were clear the first time. Have you tried running a simple 'SELECT * FROM MyTable' query from a compiled exe on PC - B? Is the problem really that it can't interact at all with a database or is it just that query on PC - B that doesn't work for some reason? Also when you installed on PC - B did you have administrative permissions on it? Are the parameters in the query the same on both machines (the values for strReportType, strDatabaseTable)?

    Office is NOT needed to interact with an Access database, at least not in the method you are using.

  8. #8
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Look here. It may address your problem.
    http://support.microsoft.com/default...NoWebContent=1
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  9. #9
    Lively Member
    Join Date
    Mar 2002
    Posts
    68
    Did Lunatic solution work for you. If not are you willing to upload your code so we can try it.

    Later

  10. #10
    Lively Member
    Join Date
    Jan 2003
    Posts
    71
    I think you should try a simple select command in place of the one you have, as someone has suggested.

    This piece looks suspicious:

    "WHERE " & strDatabaseTable & "Date LIKE "

    Do you want the tablename there? and does it need a space before Date?

  11. #11
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Date may also be a keywork and as such should be enclosed in [], but I think you said it ran fine on PC - A so I guess it can't be the code. The only thing I can think of is a Permissions problem or most likely what Lunatic posted. Good catch by the way, Lunatic.

  12. #12
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Originally posted by Edneeis
    Good catch by the way, Lunatic.
    Long live Google!
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  13. #13
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Google is like the 2nd best development aid beside the computer you're developing on...

  14. #14

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Location
    Klang, Selangor, Malaysia
    Posts
    163
    Thanks Lunatic3 and gearbolt and everyone, i think is the database file itself that cause problem. every thing is working fine now...

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