Solved

MS Access Database Connection String

Posted on 2006-11-21
10
253 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
Comment Utility
What is the ConnectionInfo object?  Is this Crystal Reports?
0
 

Author Comment

by:MeetVirginia
Comment Utility
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
Comment Utility
Try:

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


0
 

Author Comment

by:MeetVirginia
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 9

Expert Comment

by:kraffay
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry, I'm stumped.  Good Luck!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

12 Experts available now in Live!

Get 1:1 Help Now