Solved

MS Access Database Connection String

Posted on 2006-11-21
10
254 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now