How to dynamically change a Crystal Report database connection

I am new to crystal reports. I tried to implement a crystal report in my win C # application using the visual studio 2012 report wizard, so I don’t know what will happen to this in the background. Everything works well on my computer, but when I tried to install it on a different line to connect to the computer, you get an error.

I tried a lot of links like Edit dynamic link string , but since I use the report wizard to configure, I don’t know where to use it.

I also tried all the options in the report wizard for the connection string, but did not find anything that changed the connection string at runtime.

Are there any options with which I can attach connection String from app config at run time.

+4
source share
2 answers

Try something like this:

strServer= ConfigurationManager.AppSettings["ServerName"].ToString();
strDatabase= ConfigurationManager.AppSettings["DataBaseName"].ToString();
strUserID= ConfigurationManager.AppSettings["UserId"].ToString();
strPwd= ConfigurationManager.AppSettings["Password"].ToString();

report.DataSourceConnections[0].SetConnection(strServer, strDatabase, strUserID, strPwd);
+6
source
strServer= ConfigurationManager.AppSettings["ServerName"].ToString();
strDatabase= ConfigurationManager.AppSettings["DataBaseName"].ToString();
strUserID= ConfigurationManager.AppSettings["UserId"].ToString();
strPwd= ConfigurationManager.AppSettings["Password"].ToString();

//may be you need to set the integrated security to false, first.
report.DataSourceConnections[o].IntegratedSecurity = False;

report.DataSourceConnections[0].SetConnection(strServer, strDatabase, strUserID, strPwd);
+1
source

Source: https://habr.com/ru/post/1539262/


All Articles