Results 1 to 21 of 21

Thread: Password CR9 Access.mdb

  1. #1

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342

    Password CR9 Access.mdb

    Has ANYONE had any luck opening a Crystal Report through VB6, which is based on an Access.mdb, that is password protected?

    I am getting an error (CR type error):
    Run-time error '-2147189176(80047e48
    Logon failed.
    Details: DAO Error Code: Oxbd7
    Source: DAO Workspace
    Description: Not a valid password.

    VB Code:
    1. strConnectS = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    2.         "Data Source=" & App.Path & "\DB\MyDb.mdb;" & _
    3.         "Persist Security Info=True;" & _
    4.         "Jet OLEDB:Database Password=MyPassword"
    5.     With CnnStatusS
    6.         .CursorLocation = adUseClient
    7.         .Open strConnectS
    8.     End With
    9.     Set rsS = New ADODB.Recordset
    10.     Set objApp = New CRAXDRT.Application
    11.     Set objReport = objApp.OpenReport(App.Path & "\Db\" & RptSelect & ".rpt")
    12.        With objReport
    13.             Set objExportOptions = .ExportOptions
    14.         With objExportOptions
    15.             .DestinationType = crEDTDiskFile
    16.             .DiskFileName = App.Path & "\Temp\Report.pdf"
    17.             .FormatType = crEFTPortableDocFormat
    18.             .PDFExportAllPages = True
    19.         End With
    20.        
    21.         .ReadRecords

    the error occurs on the .ReadRecords

    yes, I have checked the password.
    Talk does not cook rice.
    -Chinese Proverb

  2. #2
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Why not try to check if your connection is actually working since the problem relates to LOGIN.

    VB Code:
    1. With CnnStatusS
    2. .CursorLocation = adUseClient
    3. .Open strConnectS
    4. End With
    5. 'CHECK IF YOUR CONNECTION IS ACTUALLY GOOD (1=CONNECTED, 0=FAILED)
    6. msgbox CnnStatusS.State

  3. #3

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    Thanks for your reply.

    I am getting a 1..which is connected.

    However, when I changed the drive location of the program (and associated files)....it is continueing to look at the OLD location.

    shouldnt this be being set, with the :

    VB Code:
    1. Set objReport = objApp.OpenReport(App.Path & "\Db\" & RptSelect & ".rpt")
    2.        With objReport

    ??
    Talk does not cook rice.
    -Chinese Proverb

  4. #4
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    I believe that the "app.path" is directly relative to where your vb program executable (exe) file is located. So even if you move the access table from:
    Code:
    from: 
    c:\program\Db\table.mdb
    to
    d:\program\Db\table.mdb
    and you are running the exe under c:\program, it will still take the table.mdb at c:

    Also, you have to look at two paths here, 1 is your connection string and 2 is for your CR.

    ****

    BTW, I dont use access but I may in the future so I decided to investigate a little further on the problem you have.

    I was able to simulate your LOGIN error by creating a simple access 2000 table with a password. I tried creating a connection string using JET but was not suucessful. I always got that login error even if the password was correct.

    However, I created a MS Access DSN and used ODBC to connect to the table and it worked just fine.

    Code:
    .ConnectionString = "DSN=DAO_TEST;DBQ=C:\TEST.mdb;UID=admin;Password=123456"
    Last edited by ARPRINCE; Aug 29th, 2003 at 10:21 AM.

  5. #5

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    thanks for the thoughts....

    the scenario....with app.path
    I am building on a zip disk, I have two drives attached. yesterday it was in one drive...today I placed it in the other. So program, db, report are all working of the same disk..which is in a different drive.


    However, I created a MS Access DSN and used ODBC to connect to the table and it worked just fine.
    I would have to have Access installed for this to work, wouldnt I ? or have the workgroups book? Which I am trying to stay away from....

    I would like to just attach via JET.
    Talk does not cook rice.
    -Chinese Proverb

  6. #6
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    I would have to have Access installed for this to work, wouldnt I ? or have the workgroups book? Which I am trying to stay away from....
    You don't need the access program for this. You just need the table. You also need to create a DSN using an MS-Access ODBC driver then build an ODBC connection string using the DSN instead of JET.

  7. #7

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342


    not sure where to even begin.....

    can you push start me....?
    Talk does not cook rice.
    -Chinese Proverb

  8. #8
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    I'm using WIN2K so the steps may differ a little depending on the OS you are using. Also, this is how I test
    my connection string so it may be a little awkward and long for you but it works for me just fine.

    (1) Create an MS-Access DSN.
    - Start
    - Settings
    - Control Panel
    - Administrative Tools
    - Data Sources (ODBC)
    - Click on the <SYSTEM DSN> tab
    - Click on <ADD>
    - Pick <Microsoft Access Driver (*.mdb)> my version is 4.00.6200.00
    - Click on <SELECT> and locate your access database.
    - Click on <OK>
    - Create a name for this DSN (ex. TESTMDB) to be used later
    - Click on <OK>
    - Click on <OK> again.

    (2.A) Create a VB dummy project.

    - Open VB with a new project.
    - With Form1, right click on the toolbox and click on <COMPONENTS>
    - Under the <CONTROLS> tab, add MICROSOFT ADO DATA CONTROL 6.0 (OLEDB)
    - Also add MICROSOFT DATAGRID CONTROL 6.0 (OLEDB)
    - Click on <OK>
    - Place an <ADODC1> control and a <DataGrid1> control on FORM1
    - bind the <DataGrid1> to <Adodc1>.


    (2.B) Using ADODC1, create an ODBC connections string
    - Click on <Adodc1>. Right Click and choose <ADODC Properties>.
    - Choose <USE CONNECTION STRING>
    - Under the connection string, Click on <BUILD>
    - Choose <Microsoft OLEDB PROVIDER for ODBC Drivers>
    - Click on <NEXT>
    - Choose <USE CONNECTION STRING>
    - Click on <BUILD>
    - Click on the <MACHINE DATA SOURCE>
    - Locate and pick the DSN you created under (1) which is <TESTMDB>
    - Click on <OK>
    - Type the DB login name <Admin>
    - Type the DB password <123456>
    - Click on <DATABASE>
    - locate the your DB the and click <OK>.
    - Click on <OK> again

    You should see a connection string. Copy and save this since you can use this later for you VB

    project.

    Code:
    DSN=TESTMDB;DBQ=C:\test.mdb;DefaultDir=C:;DriverId=25;FIL=MS Access;MaxBufferSize=2048;
    PageTimeout=5;PWD=123456;UID=admin;
    - Enter User name again <Admin>
    - Enter Password again <123456>
    - Place a check on <ALLOW SAVING PASSWORD>
    - Under the <initial catalog to use>, us the drop down to pick you <DATABASE>
    - Test you connection.
    - If successful, click on <OK>

    You should be back under the "PROPERTIES PAGE".

    - Click on the <RECORD SOURCE> tab
    - under the <COMMAND TYPE>, pick #2 - adcmdtable.
    - Under the <TABLE OR STORED PROCEDURE NAME>, pick the table you want to view.
    - Click on <OK>
    - Run your project (you should be able to view the table in the grid)!!!


    You basically just used the project to build and test the connection string that you can use later. You can further trim down the connection string if you want to:

    Code:
    FROM:
    
    DSN=TESTMDB;DBQ=C:\test.mdb;DefaultDir=C:;DriverId=25;FIL=MS Access;MaxBufferSize=2048;
    PageTimeout=5;PWD=123456;UID=admin;
    
    TO:
    DSN=TESTMDB;DBQ=C:\test.mdb;PWD=123456;UID=admin;

    Hope this helps!!

  9. #9

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    Dude! You Rock!

    Wont be able to work on this project until later tonite, probably. But thanks for taking the time to make such a complete set of instructions!

    I should be able to follow this step by step, and I will let you know how it goes.

    Thanks for opening my eyes to a new way of doing things. I can always use new advice!

    Thanks again!
    Talk does not cook rice.
    -Chinese Proverb

  10. #10

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    ARPRINCE, I bow to the master !

    I used your step by step, and it worked great.

    I used your information from
    http://www.vbforums.com/showthread.p...hreadid=235961

    and it worked without a hitch!!!

    I have to admit, I am beginning to regain my faith in ol' CR !!!

    This is great for working with recordsets.

    Question on the DSN (YES, I am a noob on this one)

    Do I have to deploy anything with my app, to get this to work?
    (again, user machine may not have Access...)

    definately worth 5 vbf awards for the knowledge passing on this one!
    Talk does not cook rice.
    -Chinese Proverb

  11. #11

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    ok...getting to the end here....
    taking what I learned, with what I knew....
    to come up with a report that is exported to a PDF.

    I am getting a runtime error
    Logon failed
    Details: DAO Error Code: 0xbe3
    Source: DAO.Workspace
    Description: Disk or network error

    I have gone over this code and it is not jumping out at me..

    VB Code:
    1. Dim Cap1 As String
    2.    Dim CNSTR As String
    3.    Dim RptSelect As String
    4.    Dim srcSQL As String
    5.    
    6.    CNSTR = "DSN=MYString;DBQ=C:\VBPrograms\Db\MyDb.mdb;DefaultDir=C:\VBPrograms\Db;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;PWD=MyPassword;UID=admin;"
    7.  
    8.     Set adoCN = New ADODB.Connection
    9.     Set ADOrs = New ADODB.Recordset
    10.  
    11.     ReportName = "Weekly.rpt"
    12.    
    13.     Set objApp = New CRAXDRT.Application
    14.    
    15.     With adoCN
    16.         .ConnectionString = CNSTR
    17.         .CursorLocation = adUseClient
    18.         .Open
    19.     End With
    20.  
    21.     RptSelect = cboReport.text
    22.     srcSQL = "SELECT * FROM [tblInput]  WHERE [Invoice] = '" & RptSelect & "' ORDER BY [DATE]"
    23.  
    24.     With ADOrs
    25.         .ActiveConnection = adoCN
    26.         .CursorType = adOpenDynamic
    27.         .Open srcSQL
    28.     End With
    29.    
    30.     Set objReport = objApp.OpenReport(App.Path & "\Db\" & ReportName)
    31.  
    32.     'With objReport.Database.Tables(1).ConnectionProperties
    33.         '.Item("Provider") = "XXXX"
    34.      '   .Item("Data source") = "XXXX"
    35.         '.Item("Initial Catalog") = "XXXX"
    36.       '  .Item("User ID") = "XXXX"
    37.        ' .Item("Password") = "XXXX"
    38.     'End With
    39.  
    40.         With objReport
    41.         Set objExportOptions = .ExportOptions
    42.         With objExportOptions
    43.             .DestinationType = crEDTDiskFile
    44.             .DiskFileName = App.Path & "\Temp\Report.pdf"
    45.             .FormatType = crEFTPortableDocFormat
    46.             .PDFExportAllPages = True
    47.         End With
    48.        
    49.         .ReadRecords
    50.         .DisplayProgressDialog = False
    51.         .Export (False)
    52.    
    53.     End With
    54.    
    55.    
    56.     GItems = ""
    57.     Cap1 = ""
    58.     frmPdf.Visible = True
    59.     PCaption = "Reports"
    60.     PFile = "Report"
    61.     PDir = "Temp"
    62.     Call PDFView
    63.    
    64.     MousePointer = vbNormal
    65.    
    66.     Set objTable = Nothing
    67.     Set objExportOptions = Nothing
    68.     Set objReport = Nothing
    69.     Set objApp = Nothing
    70.    
    71.    
    72.  Exit Sub

    I commented out the Database.Tables because I am unsure of the exact syntax. Each time I try something in there I get messages telling me it doesnt like the value.

    The error is arriving at the .ReadRecords line.

    Can you help on this ???
    Talk does not cook rice.
    -Chinese Proverb

  12. #12
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Do I have to deploy anything with my app, to get this to work?
    Not really as long as the DSN is configured on the client PCs.

    I believe that you should be able include the DSN configuration on your deploy package but
    I have no idea how to do that


    Do you have records in your RS?

    VB Code:
    1. With ADOrs
    2.         .ActiveConnection = adoCN
    3.         .CursorType = adOpenDynamic
    4.         .Open srcSQL
    5.     End With
    6.  'TEST IF YOU HAVE RECORDS
    7.     msgbox adors.recordcount

    if yes, try this:

    VB Code:
    1. Set objReport = objApp.OpenReport(App.Path & "\Db\" & ReportName)
    2.  
    3.    objReport.database.setdatasource adors, 3, 1
    4.  
    5.    With objReport.ExportOptions
    6.             .DestinationType = crEDTDiskFile
    7.             .DiskFileName = App.Path & "\Temp\Report.pdf"
    8.             .FormatType = crEFTPortableDocFormat
    9.             .PDFExportAllPages = True
    10.    End With
    11.    objReport.Export (False)

  13. #13

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    worked like a charm! THANKS!

    Not really as long as the DSN is configured on the client PCs.

    I believe that you should be able include the DSN configuration on your deploy package
    looks like I have some research to do...

    this will work on this application, because I can create it on the end machine....however other apps this wont be possible.

    Thanks for the assistance! I will let you know what I find out.
    Talk does not cook rice.
    -Chinese Proverb

  14. #14

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    another question...(dont mean to be a pain)

    I have a second report that I have created, based on two tables. which seems to be printing fine...

    however when I run it through the same print routine, the only thing that changes is a variable for the report name....

    it is leaving the .mdb open....

    the first one closes the .mdb as soon as the pdf is created...but the second report seems to print AND leave the db open.

    I am closing the ADOrs and the ADOcn....and setting them = nothing.

    Why would this work for one..and not the other..??
    Talk does not cook rice.
    -Chinese Proverb

  15. #15
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    What specific error do you get?
    Are you using the same code?
    How do you run the report one after the other (i.e do you have a menuy report or user types in the name of the report)?

  16. #16

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    thanks for the reply.
    not getting an error code at all. everything seems to be printing fine.

    The user has a form, with 3 option buttons on it. they select an option button, which has the report name as the .tag. This .tag is then used in a variable to select the report. (Printing one at a time)..but all using the same print routine as posted earlier.

    While running the routine, reports #1 and #3, which are based on one table only print through the crystal report routine fine and as soon as the .PDF is created, (while watching through Windows Explorer), the .ldb (associated to the .mdb) is released.

    However, when I run the #2 report, which I have based on two tables, it prints fine....however, the .ldb stays there (and if I try to delete it, it windows tells me there is someone using it). Even if I reboot the computer, the .ldb is still there.

    Do I have to do something different with the connection, etc if my report is based on two tables...??
    Talk does not cook rice.
    -Chinese Proverb

  17. #17
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Running report#1, you load the CR form. Do you unload this before calling the next report? If not, try unloading the CR form and loading it only when you start calling the next report.

  18. #18

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    no luck.

    even if I start the program (in IDE) and run the report (#2) first and then unload all forms...it still shows the database open.

    I am lost, here. I went to CR to change the database location to a different database (for grins)...and now when I try to run the routine...it is opening both of the databases..the old one and the new one....

    since I am doing this in the code (the DSN you provided) why would it matter which one was set at design time...and why would it still be trying to access it..??

    Talk does not cook rice.
    -Chinese Proverb

  19. #19

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    still no luck...

    I tried deploying to the final machine, to see if by chance the locking problem would go away...however....now I can't get the reports to work...
    Not really as long as the DSN is configured on the client PCs.
    I have tried step by step setting up the DSN and no luck...it keeps telling me the Driver (unknown) is not a valid path.

    The final machine is a W98..and I am developing on XP...is that going to make a difference with this..?

    EVERYTHING else is working fine with this program....except the reporting...
    Talk does not cook rice.
    -Chinese Proverb

  20. #20
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Originally posted by VB4fun
    no luck.

    even if I start the program (in IDE) and run the report (#2) first and then unload all forms...it still shows the database open.

    I am lost, here. I went to CR to change the database location to a different database (for grins)...and now when I try to run the routine...it is opening both of the databases..the old one and the new one....

    since I am doing this in the code (the DSN you provided) why would it matter which one was set at design time...and why would it still be trying to access it..??

    There are some issues with CR9 when you re-direct reports to another DB. You may neet to update your CR with the "HOTFIXES".

    This might help you: GO HERE!!

  21. #21
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Originally posted by VB4fun
    still no luck...
    The final machine is a W98..and I am developing on XP...is that going to make a difference with this..?
    CR9 Supports WIN98 Second Edition only.

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