Solved

MS Access Database Connection String

Posted on 2006-11-21
10
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp.net web application 3 58
Using asp.net to develop android, ios, windows APPS 7 54
Shared Service Environment 2 54
EF5: Update Model from Database not working 3 83
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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 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