// { // //setup the connection information structure // //to log on to the data source for the report. // // if using odbc, this should be the dsn. if using // // oledb, etc, this should be the physical server name // // // crconnectioninfo.servername = "dsn or server name"; // // // if you are connecting to oracle there is no // // databasename. use an empty // // string i.e. crconnectioninfo.databasename = ""; // // crconnectioninfo.databasename = "databasename"; // crconnectioninfo.userid = "your userid"; // crconnectioninfo.password = "your password"; // // // this code works for both user tables and stored // //procedures // // //get the table information from the report // crdatabase = crreportdocument.database; // crtables = crdatabase.tables; // // //loop through all tables in the report and apply the // //connection information for each table. // for (int i = 0; i < crtables.count; i++) // { // crtable = crtables [i]; // crtablelogoninfo = crtable.logoninfo; // crtablelogoninfo.connectioninfo = // crconnectioninfo; // crtable.applylogoninfo(crtablelogoninfo); // // //if your databasename is changing at runtime, specify // //the table location. for example, when you are reporting // //off of a northwind database on sql server // //you should have the following line of code: // // crtable.location = "northwind.dbo." + crtable.location.substring(crtable.location.lastindexof(".") + 1); // } // // //set the viewer to the report object to // //be previewed. // // crystalreportviewer1.reportsource = crreportdocument; // // }