Solved

MS Access Database Connection String

Posted on 2006-11-21
10
256 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete HTML table rows 12 35
How can my static class become undefined?? 8 62
No Data for DropDown List 2 27
ASP Repeater control - onl;y show if flag is true 7 15
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

789 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