Connectionstring from web.config-Crystal Reports

killme

New Member
I am having the following function to create crystal report. I want to change my function so that it uses the connection info from the web.config\[code\]MyRepository _MyRepository = new MyRepository(); System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection();myConnection.ConnectionString = "Data Source=MySRV;Initial Catalog=mydb;Persist Security Info=True;User ID=sa;Password=mypass";System.Data.SqlClient.SqlCommand MyCommand = new System.Data.SqlClient.SqlCommand("dbo.spMySP");MyCommand.Connection = myConnection;MyCommand.Parameters.Add("@PositionID", SqlDbType.Int).Value = http://stackoverflow.com/questions/4793750/(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;ASale _DS = new ASale();MyDA.Fill(_DS, "dbo.spMySP");rptSale oRpt = new rptSale();oRpt.SetDatabaseLogon("sa", "mypass");oRpt.SetDataSource(_DS);oRpt.SetParameterValue(0, "param1");oRpt.SetParameterValue(1, "param2");oRpt.SetParameterValue(2, "param3" );oRpt.SetParameterValue(3, (cmbPositions.SelectedValue =http://stackoverflow.com/questions/4793750/="" ? 0 : Convert.ToInt32(cmbPositions.SelectedValue)));CrystalReportViewer1.ReportSource = oRpt;\[/code\]Thanks
 
Back
Top