Solved

Problems with changing the connection info of a crystal report in VB.Net using SqlExpress

Posted on 2007-11-21
9
1,132 Views
Last Modified: 2008-02-01
Briefly this is the problem..

I have a module in A VB.Net called Globals in there I have 2 connection strings

Public dsn1 As String = "Data Source=192.168.999.99;Initial Catalog=recycle;Persist Security Info=True;User ID=sa;Password=sa;"
    'Public dsn2 As String = "Data Source=.\SQLExpress;Database=recycle;Uid=11;Pwd=11;" 'Single System

I first connection string  is working fine and with the click of the buttons on my forms my codes runs fine and it reads the database fine..

The problem is I had to create a crystal report...so I used the report wizard.In the database expert I picked the name of the database from the list of connections in the database expert, I chose the database which was represented in my globals as dsn1.

This works fine....

The problem is if I wanted the same report  to read the data that was represented by the database for dsn2... How would I do this the 2 databases are identical...except they are in 2 separates places..

So I followed what was at..
http://support.businessobjects.com/library/kbase/articles/c2010275.asp

This however stops at the following line when I run it ...

 crTable.Location = "recycle" & "." & "BLUE\marc" & "." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)

it says   FAILED TO LOAD DATABASE INFORMATION
              NO DATABASE dll HAS BEEN SPECIFIED

SOURCE "rptcontrollers.dll"

This is driving me around the bend...

Any help or insight before the weekend begins would be much appreciated
0
Comment
Question by:nomar2
  • 4
  • 3
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 20330772
Are they the same database type?

mlmcc
0
 

Author Comment

by:nomar2
ID: 20332055
I have a " recycle" database sitting on the sql server...maybe I set up the "recycle" database up wong on the SQL EXPRESS.

When you say type ...what exactly do you mean??
0
 

Author Comment

by:nomar2
ID: 20334296
Okay I am looking at it this way ...this is the connection string I am using for the connection into the database and it is working on my form in other words with the click of the button data is being pulled from the database and shown on the screen

Public dsn As String = "Data Source=.\SQLExpress;Database=recycle;trusted_Connection=yes;"

With this string in mind...how would I apply it to the following lines of code...with the exact syntax because it keeps saying..  FAILED TO LOAD DATABASE INFORMATION
                                          NO DATABASE dll has been specified


..so I must be missing something


        For Each crTable In crTables
            With crConnInfo
                .ServerName = servername
                 .DatabaseName = databasename
            End With
            crLogOnInfo = crTable.LogOnInfo
            crLogOnInfo.ConnectionInfo = crConnInfo
            crTable.ApplyLogOnInfo(crLogOnInfo)
        Next

        crTable.Location = databasename & "." & myowner & "." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
        crSections = cr2.ReportDefinition.Sections


How would you find out the value for "myowner" in the above line of code??

I will increase the points if I can get this working
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 20337003
Type - Are they both SQL Server 7 or is one SQL Server 7 and the other Access.  There may even be a problem with say SQL SERVER xx and SQL Server Express since they may use differnet database drivers or connection methods.

For myowner have you tried dbowner?

mlmcc
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:nomar2
ID: 20368128
After much toil...I think I came up with the solution..it seems to be working for me ( fingers crossed)
Public dsn As String = "Data Source=.\SQLExpress;Database=recycle;trusted_Connection=yes;"
        Dim cr As New rpt_SortReceipt
        Dim D As Integer
        Dim lcServerName As String = Nothing
        Dim lcDatabase As String = Nothing
        Dim lcTrusted As String
        Dim lbTrusted As Boolean

        If lnMode = 1 Then
            Dim stringItems() As String = dsn.Split(";")
            If stringItems(0) <> "" Then
                If InStr(stringItems(0), "Data Source=", CompareMethod.Text) > 0 Then
                    lcServerName = Mid(stringItems(0), 13)
                End If
            End If
            If stringItems(1) <> "" Then
                If InStr(stringItems(1), "Database=", CompareMethod.Text) > 0 Then
                    lcDatabase = Mid(stringItems(1), 10)
                ElseIf InStr(stringItems(1), "Initial Catalog=", CompareMethod.Text) > 0 Then
                    lcDatabase = Mid(stringItems(1), 17)
                End If
            End If
            If stringItems(2) <> "" Then
                If InStr(stringItems(2), "trusted_Connection=", CompareMethod.Text) > 0 Then
                    lcTrusted = Mid(stringItems(2), 20)
                    If UCase(lcTrusted) = "YES" Then
                        lbTrusted = True
                    ElseIf UCase(lcTrusted) = "NO" Then
                        lbTrusted = False
                    End If
                End If
            End If

            ' MsgBox(lcServerName)
            ' MsgBox(lcDatabase)
            ' MsgBox(lbTrusted)

            cr.DataSourceConnections.Item(0).SetConnection(lcServerName, lcDatabase, lbTrusted)
            ' cr.SetDatabaseLogon("sa", "sa") ' commented out for my case
            cr.RecordSelectionFormula = "{tInv.IID}= " & lnBeginID & ""
            For D = 1 To 1
                cr.SetParameterValue("prm_InvoiceID", D)
                cr.PrintToPrinter(1, False, 0, 0)
            Next

End If
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 20557249
Since the answer is provided, how about PAQ/Refund

mlmcc
0
 

Author Comment

by:nomar2
ID: 20590070
I have been using the above solution and it is working perfectly...
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20591160
PAQed with points refunded (50)

Computer101
EE Admin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

19 Experts available now in Live!

Get 1:1 Help Now