Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing odbc instance
Message
General information
Forum:
Visual FoxPro
Category:
Crystal Reports
Miscellaneous
Thread ID:
01017245
Message ID:
01017306
Views:
19
Federico,
We have a similar situation where the crystal report needs to run against either the production database or the test database. Here's an example of how to change all of the connection settings for the crystal report. Our reports use OLEDB provider but you should be able to do something similar with an ODBC connection. You may need to have seperate DSN's for each server however.
*	Loop through each table in the report
FOR lnCounter = 1 TO loReport.Database.Tables.Count
	WITH loReport.Database.Tables(lnCounter).ConnectionProperties
		*	Save the current table name
		lcLocation = loReport.Database.Tables(lnCounter).Location
		
		*	Clear the current connection properties
		.DeleteAll()
		
		*	Set the connection properties to the correct server
		.Add('Provider','SQLOLEDB')
		.Add('Data Source',lcServerName)
		.Add('Initial Catalog',lcDatabase)
		.Add('Integrated Security',0)			
		.Add('Password',lcPassword)			
		.Add('User ID',lcUserId)		
		
		*	Reset the table location
		loReport.Database.Tables(lnCounter).Location = lcLocation
	ENDWITH
ENDFOR
Hope this helps,
Kurt
>I have 8 directories (dir1 dir2, dir3....dir8) with file1, file2, file3 in each one. In other directory called "cansolid" I have the odbc instance of each directory (pointing to..). I do this because i have 8 accountings (is that the name????) for the same number of entities. Additionally, I have a directory i wich i have ther reports. (here comes the point) I made a report wich uses 4 subreports all of then using the odbc instance that points to the dir2 works like a charm. I made an interface using the crystal report control to print the report, it works fine, but when i want to programatically change the odbc instance to use the files in dir6 it prints dir2 information.
>How do I change programatically an instance of odbc as if I were "setting the location" of the files using the crystal report program, even more is there a way to expand automatically the changes to the sub report?
Previous
Reply
Map
View

Click here to load this message in the networking platform