CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Question Data Access Error

    I have prepared a code to draw graphics .I have used Excell sheet as a data file as well as I have used Excel to fill combo list. Both works fine on my pc but after creating setup file and installing the same on another pc it gives error "Data Access Error" please give guidence to solev it.It ia important and urgent also...please

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Data Access Error

    Unless you post some code, how are we suppoosed to know why the error is coming.

    Probably you haven't packaged the Excel file alongwith your setup package. Or maybe something else.

    Try to see where the Error is coming and then post the code that is giving you the error, then only people will be able to help you.

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Data Access Error

    Do you have Excel installed on that machine to where you ported your code.? Because even written fully in VB accessing Excel, it would not work when you dont have Excel on your machine. But as said by Shuja please post the codepart where it crashes and the exact error message.

    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  4. #4
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: Data Access Error

    ok though code is large the connecting code I am pasting here which excecutes when form load..
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    cd1.DialogTitle = "Select your datafile"
    cd1.ShowOpen

    Dim fileopen As String
    cd1.Filter = "xls"
    fileopen = cd1.FileName
    Data1.DatabaseName = fileopen
    Data1.RecordSource = "acchod$"
    MsgBox fileopen, vbOKOnly, "Your Data file is...."
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    "acchod$" is name of sheet of selected excel file

    code works on machine on which I have developed this application. I have developed this application on system on which Windo 98 was installed and now on same code I am working on widows xp plateform and office 2003.the earlier setup was window98 and office 2000.

    Answer to JONEY POET that yes Excel is installed on the amchine on which this error displays.

    Even on new pateform it works but I think the condition is unelss VB is installed.
    Last edited by mynick; January 25th, 2006 at 05:54 AM.

  5. #5
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: Data Access Error

    tx in advance
    Last edited by mynick; January 25th, 2006 at 05:53 AM.

  6. #6
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Data Access Error

    I would suggest that you include the logging capability in the application and log all the error messages to a file. And don't forget to have proper error handling in your program.

  7. #7
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Data Access Error

    If you cannot debug it on the machine where you get the error then set lineNumbers in the program and catch errormessages from the functions where you assume the error may occur. Add the linenr to the output of the err messageBox so you will see where the erro occurs. You got the idea The errormessage then may look like: 'Err Nr... Description... after line xxx in function yyyy'
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  8. #8
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: Data Access Error

    can anyone show some lines of code for logging purpose..

  9. #9
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Data Access Error

    Quote Originally Posted by mynick
    can anyone show some lines of code for logging purpose..
    Append to Log File

    Just make sure that you call this function everytime you want to append any message to the logfile.

  10. #10
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Data Access Error

    Quote Originally Posted by mynick
    can anyone show some lines of code for logging purpose..
    For getting linenumbers ito the errormessage do the following in the critical function where you think the error comes from
    Code:
    'Pseudocode
    Private Function MyProblemCaseFunction(xy as Input ) z as output
    Dim iLine as integer
    ' and where the code begins after declaration
    On error goto ErrHnd
    iLine = 0
    Mycode = AnyCode(FirstLine)
    iLine = iLine +1
    Nextcodeline = ...
    iLine = iLine +1
    Nextcodeline
    ,,,,
    Exit Function
    ErrHnd: 
    Call MsgBox("Error " & Err.Number & Err.Description & "in MyProblemCaseFunction Line " & CStr(iLine))
    Err.Clear
    'Add ErrorHandling here
    End Function
    You also can add Shujas LogFile here if you want
    and adding Linenumber Data to his datainput. As you see this is work.
    So in difficult cases I did it step by step. At first I did it in the superordinated Procedure I had. Assume I had an error in a storing Proedure This procedure has lots of steps and subfunctions in it
    Code:
    Pseudocode only brackets are set for better to see begin and end
    MyStoreFunction()
    {
    iLine = 1
    validateData
    	 {
    	 SubFunction1
    	 SubFunction2
    	 ... 
    	 }
     
    iLine = iLine +1
    StoreCustomerToDatabase	
    	 {
    	 if CheckIfNameExists
    		 if Compare ExistingData
    				ShowDifferencesOnScreen	 
    				GetHandlingFromUser
    				StoreCorrespondingToInput 
    		 else
    				StoreDataAsTheyAre
    		 end if 
    	 else AddNewData 
    	 }
    iLine = iLine +1
    StoreJobToDatabase
    iLine = iLine +1 
    Print JonDokument
    iLine =iLine+1
    PushDataRefresh
    errHandler ( as shown in first Example ) 
    }
    As you see I did it in the MyStoreFunctin. Then I found ot error is in StoreCustomerToDatabase Then I did the same procedure in that
    Until at least I would found its in line 34 of StoreDataAsTheyAre Function.
    I hope that helps a bit JonnyPoet (jun )
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

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

Featured