Solved

MS Access Database Connection String

Posted on 2006-11-21
10
255 Views
Last Modified: 2008-02-01
Help!  I'm using some code for a ReportDocument object that's connecting to an SQL database.  I need the connection object to point to an Access database.  Can someone please tell me how to modify this code to do this?  There is not a username or password on the access database, I just need the database info.

    Private Sub ConfigureCrystalReports()

        AccessTest = New ReportDocument()

        Dim reportPath As String = Server.MapPath("Reports/AccessTest.rpt")
        Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

'This is the SQL Server connection data that I need to change to an Access connection:

        myConnectionInfo.ServerName = "MyServer"
        myConnectionInfo.DatabaseName = "DatabaseName"
        myConnectionInfo.UserID = "TestUser"
        myConnectionInfo.Password = "TestPassword"

        myCrystalReportViewer.ReportSource = AccessTest
        AccessTest.Load(reportPath)
        SetDBLogonForReport(myConnectionInfo)

    End Sub

THis is extremely urgent - any resolution will be greatly appreciated!
0
Comment
Question by:MeetVirginia
  • 5
  • 4
10 Comments
 
LVL 9

Expert Comment

by:kraffay
ID: 17989312
What is the ConnectionInfo object?  Is this Crystal Reports?
0
 

Author Comment

by:MeetVirginia
ID: 17989369
The function runs an embedded Crystal Report.  The ConnectionInfo object passes the connection information.  Without it, the CrystalReportViewer or source object defaults to a log on screen.  I just need to know how to revise the connection string to hit an access database instead of a SQL database (OLE DB?).

Thanks!
0
 
LVL 9

Expert Comment

by:kraffay
ID: 17989444
Try:

myConnectionInfo.ServerName = "C:\mydatabase\mydata.mdb"


0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:MeetVirginia
ID: 17990075
That works until the web site is published to the web server.  I even changed it to read:

myConnectionInfo.ServerName = Server.MapPath("mydatabase/mydata.mdb")

Any ideas?

Thanks!!!
0
 

Author Comment

by:MeetVirginia
ID: 17990147
Actually, I had the object prompting for a login.  I changed the property to false.  Now I'm getting the error:

Error: Object reference not set to an instance of an object.

Don't I have to give a provider name, etc.?  The path worked locally, but not on the server.  Is that because Access isn't installed on the web server?

Thanks again!!
0
 
LVL 9

Expert Comment

by:kraffay
ID: 17990710
Is that the correct path to the MDB on the server?  And no, Access doesn't have to be installed on the server, just the .NET Framework -- it provides the OleDB layer.
0
 

Author Comment

by:MeetVirginia
ID: 17990785
Server.MapPath("mydatabase/mydata.mdb") is the correct path on the server.  I also just saw, when I ran the page again, in a different area (above the CrystalReportsViewer object) the message "Database Logon Failed".  It's an unsecured database, with no password.  And yes, the .NET Framework is on the server.  I'll keep looking...
0
 
LVL 10

Expert Comment

by:SystemExpert
ID: 17994640
Hi,

If u use MS Access and Crystal Report than

Connect your database (MS Access) through DAO . File based Connection

In Crystal Report to get the Path Dynamically

With CrystalReport1
    .ReportFileName = "C:\YourReport.rpt"
    .Connect = "DSN=ODBC_DSN_Name;UID=Username;PWD=Password;DBQ=dbName"
    .Action = 1
End With

Thanks
0
 

Author Comment

by:MeetVirginia
ID: 17994953
Where does this go??  This is my code behind page:

Option Strict On

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Collections
Imports System.Data.OleDb

Partial Class AccessTest
    Inherits System.Web.UI.Page

    Private AccessTest As ReportDocument

    Private Sub ConfigureCrystalReports()

        AccessTest = New ReportDocument()

        Dim reportPath As String = Server.MapPath("Reports/AccessTest.rpt")
        Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

        myConnectionInfo.DatabaseName = Server.MapPath("AccessTest/ARMT.mdb")
        myConnectionInfo.UserID = ""
        myConnectionInfo.Password = ""

        CrystalReportViewer1.ReportSource = AccessTest
        AccessTest.Load(reportPath)

    End Sub



    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        ConfigureCrystalReports()

    End Sub


End Class

The database is in a folder with the project so when I publish the project, it gets published also and I'm trying to use the server.mappath method.  OMG!  This has been a nightmare, but we have to have this project up today.  Ugh!  I also tried a walkthrough from Business Objects but it didn't work.  I'm completely lost.  Thanks!

0
 
LVL 9

Accepted Solution

by:
kraffay earned 500 total points
ID: 17997291
Sorry, I'm stumped.  Good Luck!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 47
IIS redirect 1 68
ck editor is taking too much time to be loaded in asp 1 18
Following an example - Why do I need to click Save button twice? 3 25
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question