asp.net - Connectionstring from web.config-Crystal Reports -
i having following function create crystal report. want change function uses connection info web.config
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 = (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 == "" ? 0 : convert.toint32(cmbpositions.selectedvalue))); crystalreportviewer1.reportsource = orpt;
thanks
myconnection.connectionstring = configurationmanager .connectionstrings["constrname"] .connectionstring;
Comments
Post a Comment