Solved

login window comes in crystal reports vb.net

Posted on 2004-09-22
15
508 Views
Last Modified: 2008-01-09
hi
i have developed crystal reports (vb.NET 2003 version)
it asks for Login and server name etc.
i mena in report viewer login window comes .. this happens when the server is changed
for example client side or installatin site..

but in my code i am also allocating login info and stuff run time.

belolw is the code that does that

-----------------------------------------------------------
rep.Load(Application.StartupPath & "\report\" & rptFileName)
' loading  rpt file

       
'-- below constr is the connection string info for SQL server
'-- i am splitting information to get server name and pwd and uid stuff from app.config file ia

have made
'
   Private Sub InitializeReport()
        rep.Load(Application.StartupPath & "\report\" & rptFileName)
     
        Dim tempservinfo() As String = Split(strConnect, ";")
        Dim server, database, uname, pword
        server = Split(tempservinfo(0), "=")
        database = Split(tempservinfo(1), "=")
        If tempservinfo.Length > 3 Then
            uname = Split(tempservinfo(2), "=")
            pword = Split(tempservinfo(3), "=")
        Else
            uname = ""
            pword = ""
        End If
        rep.SetDatabaseLogon(uname(1), pword(1), server(1), database(1))
        Dim MyLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
        Dim MyTable As CrystalDecisions.CrystalReports.Engine.Table
        For Each MyTable In rep.Database.Tables


            MyLogonInfo = MyTable.LogOnInfo
            If (MyTable.Name = "") Then
                MyLogonInfo.ConnectionInfo.UserID = uname(1)
                MyLogonInfo.ConnectionInfo.Password = pword(1)
                MyLogonInfo.ConnectionInfo.ServerName = server(1)
                MyLogonInfo.ConnectionInfo.DatabaseName = database(1)
            Else
                MyLogonInfo.ConnectionInfo.UserID = uname(1)
                MyLogonInfo.ConnectionInfo.Password = pword(1)
                MyLogonInfo.ConnectionInfo.ServerName = server(1)
                MyLogonInfo.ConnectionInfo.DatabaseName = database(1)
                MyTable.ApplyLogOnInfo(MyLogonInfo)
            End If
           


        Next
        CrystalReportViewer1.ReportSource = rep

' rep variable is report document

        CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.ServerName = server(1)
        CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.DatabaseName = database(1)
        CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.UserID = uname(1)
        CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.Password = pword(1)

        CrystalReportViewer1.SelectionFormula = rptSelectFormula
    End Sub
-------------------------------------------------------------------------

in above code everything works fine i have checked while doing debugging and all information

goes properly but then also that login window comes

also the thing is i am not using tables straight away in reports for data
i am using view and qeries i have built in databse.

any help would be helpfull   ASAP plz
thanx in advance
Nilesh
0
Comment
Question by:nilesh_parmar
  • 5
  • 5
  • 5
15 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 12122952
Does the user have permissions to the database and table?

Does the report have a subreport?

mlmcc
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12122984
Change it to this. it will work. Your problem was you used two object models to set logon, viewer and engine. Use engine only.
Regards
Emre.

-----------------------------------------------------------
rep.Load(Application.StartupPath & "\report\" & rptFileName)
' loading  rpt file

       
'-- below constr is the connection string info for SQL server
'-- i am splitting information to get server name and pwd and uid stuff from app.config file ia

have made
'
   Private Sub InitializeReport()
        rep.Load(Application.StartupPath & "\report\" & rptFileName)
     
        Dim tempservinfo() As String = Split(strConnect, ";")
        Dim server, database, uname, pword
        server = Split(tempservinfo(0), "=")
        database = Split(tempservinfo(1), "=")
        If tempservinfo.Length > 3 Then
            uname = Split(tempservinfo(2), "=")
            pword = Split(tempservinfo(3), "=")
        Else
            uname = ""
            pword = ""
        End If
       
        Dim MyLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
        Dim MyTable As CrystalDecisions.CrystalReports.Engine.Table
        For Each MyTable In rep.Database.Tables


            MyLogonInfo = MyTable.LogOnInfo
            If (MyTable.Name = "") Then
                MyLogonInfo.ConnectionInfo.UserID = uname(1)
                MyLogonInfo.ConnectionInfo.Password = pword(1)
                MyLogonInfo.ConnectionInfo.ServerName = server(1)
                MyLogonInfo.ConnectionInfo.DatabaseName = database(1)
            Else
                MyLogonInfo.ConnectionInfo.UserID = uname(1)
                MyLogonInfo.ConnectionInfo.Password = pword(1)
                MyLogonInfo.ConnectionInfo.ServerName = server(1)
                MyLogonInfo.ConnectionInfo.DatabaseName = database(1)
                MyTable.ApplyLogOnInfo(MyLogonInfo)

            End If  
                MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);  
        Next
        CrystalReportViewer1.ReportSource = rep

'        CrystalReportViewer1.SelectionFormula = rptSelectFormula
    End Sub
-------------------------------------------------------------------------
0
 

Author Comment

by:nilesh_parmar
ID: 12128176
yes
report has subreports

second thing i am not using tables from the database ,
i am using views
to get data

 ebolek  i have done your way also but still  its coming also

near the line

  MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1)

i get error saying eron in report , invalid table number
may as i have said i am using the views..

as far as i know the solutio for this is to go to
clients'site  hook your laptop, in theire network and then map SQL server , then do set location and verify database in all your reports and then make build and deploy those rpt files on client machine,

but this is not th right way i mean most of companies dont want others to coonect their servers and services...

still clueless and  we are now in deployment phase..

Nilesh.

0
 
LVL 10

Expert Comment

by:ebolek
ID: 12132615
The view jshould work just fine. Table can be table, view, sp etc.Also what data do you get when you watch the mytable object. I have used that code saeveral times so it wotks. You have another problem. I think you can not connect to the database. Is the report declared as sql authentication. Shouls be. Does the user have access to the views. Check for permissions

Regards
Emre
0
 

Author Comment

by:nilesh_parmar
ID: 12148075
i also think there is problem with login
during design time of report on my development machine,
i set location for the sql server running on my machine also that time i set windows authentication(inte security).
but at run time i  am giving all information for log in and connection so it should pick it up

now above kind of code works fine with ACCESS database , but when  it comes to sql server there is prob

1 more thing is

if crystal reports are running on same machine which has SQL server running then above code works fine  ...doen't matter if SQL name and log in is changed , it picks info and does the job,
BUT
when crystal reports are running on sql client machine thats where problem comes..
and obviously second one will be the case in most of customers site , you will install your applicaton on client machine.. so
thats problem..

thanx mate

NIlesh
0
 

Author Comment

by:nilesh_parmar
ID: 12148092
1 more thing iis the log in i use to connect SQL server is sa  so it has all right s for all dbase and stuff

but do i  have to check permissions for views also?

and you said some thing about report to declared as SQL authen. what does that mean ?

thanx

Nilesh
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 40 total points
ID: 12149005
I won't swear to this but if you use integrated security to build the report then it will run with with integrated security and ignore the passed in values.  To continue using integrated security you will need to add all users to the server and set permissions for the tables, views, and stored provedures.

If you wish to pass the login information change the report to use SQL authentication.

mlmcc
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:ebolek
ID: 12159885
SQL authentication

You embed the user and password nformation to the report when you design the rpeort. Report doesnt save the password information for security reasons. Therefore whenever you run the report, you have to supply the password info to the report. If you want to chnage the suer in runtime, you do that by supplying anoyther username and pwd to the report.

Integrated security:
Report uses the NT logon information. Whoever runs the report, report gets the login info from the operating system and checks the credentials, There is usually a big problem when using NT if you want to chnage the db and server in runtime. So you better check with the knowlede base when doing that and see if your version has a bug in this subject

Regards
Emre
0
 

Author Comment

by:nilesh_parmar
ID: 12165011
hey
mlmcc
thanx for your comment,
i thought thsat reason at first and then i forgot it trying solution s from net and , business objects

but any way i did try this solution and it worked

if during design time i assign integrated security to report then
it will never  run on client machine where SQL client is connected via SQL authentication(uid, pwd)

and if  at design time  i design report with SQL authentication then it will only run on client side where they use SQL authentication

bcz
remeber when you do set location .. the window comes where we make connection oledb sql server
at that time  if you are using integrated security
then left hand side parameters will show tht
inte.  security is set to TRUE
other wise it will be set to FAlse

thats where prob comes
bcz
as per my knowledge there is no way that you can change report's INTEGRATED SECURITY PARAMETER VALUE DURING  UN TIME
YOU CAN CHANGE USER , PWORD AND DATABSE AND SERVER NAME SUFF BUT
NOT THE BOOLEAN INTEGRATED SECURITY PARAMETERS

so my question is any one knows how to change that parameter also during run time? i mean in code
i tried with rep document  objects property but there is also nothing..

i wil aso try to ask business objects(crystal  guys)

but any way
thanx for all your reply..

i am accepting answer from mlmcc..

but still plz let me know abt int security run  time value assigning problem..
thanx
Nilesh
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12166269
Glad I could help

mlmcc
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12168827
I tried to explain to you that but you didnt like the answer. I posted how to chnage the user and pwd information in .net too for sql authentication. Good luck with chnaging the database information if you use integrated security
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12174869
>>so my question is any one knows how to change that parameter also during run time?
I doubt that it can be changed from code.  It may be possible with the ROyalty Required runtime but even there I doubt it.

mlmcc
0
 

Author Comment

by:nilesh_parmar
ID: 12178067
ebolek
buddy, dont be angry ....
i have noticed once you have written"   Is the report declared as sql authentication. Shouls be"

any way so what do you want me do?

accept your answer also ? or make it as assitancing answer or someting....

i dont know how to do that.. bcz now those options(accept button)  are not here...

i dont mind about  the points man,

but i your above comment is more assiting then exact solution.. you have said it should be SQL authentication but why? and what? stuff like  is not there

any way forget about all
you have also spent time to give me answer so if you want points then i dont mind... but i dont know how to allocate to you now....

also if you know that integrated security changing at run time then let me know...

thanx
Nilesh
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12179188
I am not angry, you did the right think. Mlmcc knows more tahn I do any way.

Good luck
Emre
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12185598
That is not necessarily true.  My knowledge is limited to CR8 and VB applications.  The rest I am picking up here or through the CR knowledge base.

If you wish, submit a request in the Community Support TA to split the points or reopen it.

mlmcc
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

20 Experts available now in Live!

Get 1:1 Help Now