Solved

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

Posted on 2007-11-21
9
1,141 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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
 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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