nilesh_parmar
asked on
login window comes in crystal reports vb.net
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.Start upPath & "\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.Start upPath & "\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.Ta bleLogOnIn fo
Dim MyTable As CrystalDecisions.CrystalRe ports.Engi ne.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 .ServerNam e = server(1)
MyLogonInfo.ConnectionInfo .DatabaseN ame = database(1)
Else
MyLogonInfo.ConnectionInfo .UserID = uname(1)
MyLogonInfo.ConnectionInfo .Password = pword(1)
MyLogonInfo.ConnectionInfo .ServerNam e = server(1)
MyLogonInfo.ConnectionInfo .DatabaseN ame = database(1)
MyTable.ApplyLogOnInfo(MyL ogonInfo)
End If
Next
CrystalReportViewer1.Repor tSource = rep
' rep variable is report document
CrystalReportViewer1.LogOn Info(0).Co nnectionIn fo.ServerN ame = server(1)
CrystalReportViewer1.LogOn Info(0).Co nnectionIn fo.Databas eName = database(1)
CrystalReportViewer1.LogOn Info(0).Co nnectionIn fo.UserID = uname(1)
CrystalReportViewer1.LogOn Info(0).Co nnectionIn fo.Passwor d = pword(1)
CrystalReportViewer1.Selec tionFormul a = 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
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.Start
' 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.Start
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
Dim MyLogonInfo As CrystalDecisions.Shared.Ta
Dim MyTable As CrystalDecisions.CrystalRe
For Each MyTable In rep.Database.Tables
MyLogonInfo = MyTable.LogOnInfo
If (MyTable.Name = "") Then
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
Else
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyTable.ApplyLogOnInfo(MyL
End If
Next
CrystalReportViewer1.Repor
' rep variable is report document
CrystalReportViewer1.LogOn
CrystalReportViewer1.LogOn
CrystalReportViewer1.LogOn
CrystalReportViewer1.LogOn
CrystalReportViewer1.Selec
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
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.Start upPath & "\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.Start upPath & "\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.Ta bleLogOnIn fo
Dim MyTable As CrystalDecisions.CrystalRe ports.Engi ne.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 .ServerNam e = server(1)
MyLogonInfo.ConnectionInfo .DatabaseN ame = database(1)
Else
MyLogonInfo.ConnectionInfo .UserID = uname(1)
MyLogonInfo.ConnectionInfo .Password = pword(1)
MyLogonInfo.ConnectionInfo .ServerNam e = server(1)
MyLogonInfo.ConnectionInfo .DatabaseN ame = database(1)
MyTable.ApplyLogOnInfo(MyL ogonInfo)
End If
MyTable.Location = MyTable.Location.Substring (MyTable.L ocation.La stIndexOf( ".")+1);
Next
CrystalReportViewer1.Repor tSource = rep
' CrystalReportViewer1.Selec tionFormul a = rptSelectFormula
End Sub
-------------------------- ---------- ---------- ---------- ---------- -------
Regards
Emre.
--------------------------
rep.Load(Application.Start
' 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.Start
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.Ta
Dim MyTable As CrystalDecisions.CrystalRe
For Each MyTable In rep.Database.Tables
MyLogonInfo = MyTable.LogOnInfo
If (MyTable.Name = "") Then
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
Else
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyLogonInfo.ConnectionInfo
MyTable.ApplyLogOnInfo(MyL
End If
MyTable.Location = MyTable.Location.Substring
Next
CrystalReportViewer1.Repor
' CrystalReportViewer1.Selec
End Sub
--------------------------
ASKER
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.L ocation.La stIndexOf( ".")+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.
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
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.
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
Regards
Emre
ASKER
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
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
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
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
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
Glad I could help
mlmcc
mlmcc
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
>>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
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
ASKER
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
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
I am not angry, you did the right think. Mlmcc knows more tahn I do any way.
Good luck
Emre
Good luck
Emre
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
If you wish, submit a request in the Community Support TA to split the points or reopen it.
mlmcc
Does the report have a subreport?
mlmcc