myRpt report = new myRpt(); crConnectionInfo.ServerName = @"mysharedserver.com"; crConnectionInfo.DatabaseName = "mydb"; crConnectionInfo.UserID = "myuser"; crConnectionInfo.Password = "mypass"; System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(); myConnection.ConnectionString = "Data Source=mysharedserver.com;Initial Catalog=mydb;Persist Security Info=True;User ID=myuser;Password=mypass"; System.Data.SqlClient.SqlCommand MyCommand = new System.Data.SqlClient.SqlCommand("dbo.spspMyStoreProc"); MyCommand.Connection = myConnection; MyCommand.Parameters.Add("@PositionID", SqlDbType.Int).Value = (cmbPositions.SelectedValue == "" ? 0 : Convert.ToInt32(cmbPositions.SelectedValue)); MyCommand.CommandType = System.Data.CommandType.StoredProcedure; System.Data.SqlClient.SqlDataAdapter MyDA = new System.Data.SqlClient.SqlDataAdapter(); MyDA.SelectCommand = MyCommand; myDS _DS = new myDS(); MyDA.Fill(_DS, "dbo.spspMyStoreProc"); report.SetDataSource(_DS); crDatabase = report.Database; crTables = crDatabase.Tables; for (int i = 0; i < crTables.Count; i++) { crTable = crTables[i]; crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectionInfo; crTable.ApplyLogOnInfo(crTableLogOnInfo); } report.SetParameterValue(0, "Param 1"); report.SetParameterValue(1, "Param 2"); report.SetParameterValue(2, "Param 3"); report.SetParameterValue(3, (cmbPositions.SelectedValue == "" ? 0 : Convert.ToInt32(cmbPositions.SelectedValue))); CrystalReportViewer1.ReportSource = report;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)