Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I know BackgroundWorker work complete? Pin
N a v a n e e t h18-Sep-08 19:28
N a v a n e e t h18-Sep-08 19:28 
AnswerRe: How do I know BackgroundWorker work complete? Pin
#realJSOP18-Sep-08 23:57
professional#realJSOP18-Sep-08 23:57 
QuestionHow to compress and decompress an image using GDI+ JPEG? Pin
gigahertz20518-Sep-08 17:57
gigahertz20518-Sep-08 17:57 
AnswerRe: How to compress and decompress an image using GDI+ JPEG? Pin
Anthony Mushrow19-Sep-08 1:02
professionalAnthony Mushrow19-Sep-08 1:02 
QuestionOutlook Issue. Newbie Question Pin
kruegersck18-Sep-08 17:33
kruegersck18-Sep-08 17:33 
QuestionFIB Pin
Miss_hacker18-Sep-08 16:09
Miss_hacker18-Sep-08 16:09 
QuestionCan i write a small plugin for Internet Explorer in .Net ? Pin
SWSDEV18-Sep-08 14:28
SWSDEV18-Sep-08 14:28 
QuestionCrystal Reports Help Pin
Alldaypilot18-Sep-08 14:10
Alldaypilot18-Sep-08 14:10 
Hi,

I'm new to Crystal Reports and this is the first report I have written. Heres the problem: I've generated a report viewer that automatically logs in to the SQL server to pull the data. This part works fine and shows the report. I have also created two date pickers for the user to select a date range and refresh the report. When the user clicks the generate button, a Crystal Database login window prompt opens. All the information is already filled in except the password.

How can I make it so this refreshed report also automatically logs in.

<br />
namespace Val_Report<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
<br />
<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void Form1_Load(object sender, EventArgs e)<br />
        {<br />
            //Set up database and report path<br />
            ConfigureCrystalReports();<br />
            <br />
            //Set Report Dates Initially at first of month to current date<br />
<br />
            //Get first day of month<br />
            DateTime firstDay = DateTime.Now;<br />
            DateTime FirstDayInMonth = new DateTime(firstDay.Year, firstDay.Month, 1);<br />
            string strStartDate = FirstDayInMonth.ToShortDateString();<br />
            //Set the orderStartDate TimePicker to value<br />
            orderStartDate.Value = FirstDayInMonth;<br />
<br />
            //Get current date<br />
            string strEndDate = DateTime.Now.ToShortDateString();<br />
<br />
            //Set the orderEndDate TimePicker to value<br />
            orderEndDate.Value = DateTime.Now;<br />
<br />
            //Set up my report parameters (date, etc)<br />
            setReportParameters(strStartDate, strEndDate);<br />
        }<br />
<br />
        private void ConfigureCrystalReports()<br />
        {<br />
            //Set up sql connection<br />
            ConnectionInfo connectionInfo = new ConnectionInfo();<br />
            connectionInfo.ServerName = "xxx";<br />
            connectionInfo.DatabaseName = "xxx";<br />
            connectionInfo.UserID = "xxx";<br />
            connectionInfo.Password = "xxx";<br />
           <br />
            //Set report path<br />
            string reportPath = Application.StartupPath + "\\" + "CrystalReport1.rpt";<br />
            crystalReportViewer.ReportSource = reportPath;<br />
            <br />
            //Make sure we iterate through all the tables<br />
            SetDBLogonForReport(connectionInfo);<br />
<br />
        }<br />
<br />
        private void SetDBLogonForReport(ConnectionInfo connectionInfo)<br />
        {<br />
            TableLogOnInfos tableLogOnInfos = crystalReportViewer.LogOnInfo;<br />
            foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)<br />
            {<br />
                tableLogOnInfo.ConnectionInfo = connectionInfo;<br />
<br />
            }<br />
<br />
        }<br />
<br />
<br />
        private void crystalReportViewer_Load(object sender, EventArgs e)<br />
        {<br />
<br />
        }<br />
<br />
<br />
        private void setReportParameters(string strStartDate, string strEndDate)<br />
        {<br />
<br />
            // all the parameter fields will be added to this collection <br />
            ParameterFields paramFields = new ParameterFields();<br />
          <br />
            // the parameter fields to be sent to the report <br />
            ParameterField pfStartDate = new ParameterField();<br />
            ParameterField pfEndDate = new ParameterField();<br />
<br />
            // setting the name of parameter fields with wich they will be recieved in report <br />
<br />
            pfStartDate.ParameterFieldName = "StartDate";<br />
            pfEndDate.ParameterFieldName = "EndDate";<br />
<br />
            // the above declared parameter fields accept values as discrete objects <br />
            // so declaring discrete objects <br />
            ParameterDiscreteValue dcStartDate = new ParameterDiscreteValue();<br />
            ParameterDiscreteValue dcEndDate = new ParameterDiscreteValue();<br />
<br />
            // setting the values of discrete objects <br />
           <br />
            dcStartDate.Value = DateTime.Parse(strStartDate);<br />
            dcEndDate.Value = DateTime.Parse(strEndDate);<br />
<br />
            // now adding these discrete values to parameters  <br />
           <br />
            pfStartDate.CurrentValues.Add(dcStartDate);<br />
            pfEndDate.CurrentValues.Add(dcEndDate);<br />
<br />
            // now adding all these parameter fields to the parameter collection <br />
          <br />
            paramFields.Add(pfStartDate);<br />
            paramFields.Add(pfEndDate);<br />
<br />
            /* Set the modified parameters collection back to the viewer so that<br />
             the new parameter information can be used for the report. */<br />
            crystalReportViewer.ParameterFieldInfo = paramFields;<br />
        }<br />
<br />
        private void redisplay_Click_1(object sender, EventArgs e)<br />
        {<br />
<br />
           // ConfigureCrystalReports();<br />
            <br />
            string strStartDate = orderStartDate.Text;<br />
            string strEndDate = orderEndDate.Text;<br />
<br />
            string reportPath = Application.StartupPath + "\\" + "CrystalReport1.rpt";<br />
            crystalReportViewer.ReportSource = reportPath;<br />
<br />
            setReportParameters(strStartDate, strEndDate);<br />
        }<br />
<br />

QuestionRead already opened file Pin
srabik18-Sep-08 13:27
srabik18-Sep-08 13:27 
AnswerRe: Read already opened file Pin
Guffa18-Sep-08 21:20
Guffa18-Sep-08 21:20 
GeneralRe: Read already opened file Pin
srabik20-Sep-08 3:48
srabik20-Sep-08 3:48 
QuestionMouseMove in a container [modified] Pin
Rafone18-Sep-08 13:05
Rafone18-Sep-08 13:05 
AnswerRe: MouseMove in a container Pin
Ajay.k_Singh18-Sep-08 19:51
Ajay.k_Singh18-Sep-08 19:51 
GeneralRe: MouseMove in a container Pin
Rafone19-Sep-08 2:33
Rafone19-Sep-08 2:33 
GeneralRe: MouseMove in a container Pin
Ajay.k_Singh19-Sep-08 3:31
Ajay.k_Singh19-Sep-08 3:31 
GeneralRe: MouseMove in a container Pin
Rafone19-Sep-08 5:31
Rafone19-Sep-08 5:31 
AnswerRe: MouseMove in a container Pin
Rafone19-Sep-08 6:50
Rafone19-Sep-08 6:50 
QuestionCan a template parameter be restricted to primitive types? Pin
HosamAly18-Sep-08 11:24
HosamAly18-Sep-08 11:24 
AnswerRe: Can a template parameter be restricted to primitive types? Pin
Pete O'Hanlon18-Sep-08 11:31
mvePete O'Hanlon18-Sep-08 11:31 
GeneralRe: Can a template parameter be restricted to primitive types? Pin
HosamAly19-Sep-08 23:38
HosamAly19-Sep-08 23:38 
QuestionConcatenation or Data Type problem :s Pin
Muammar©18-Sep-08 11:11
Muammar©18-Sep-08 11:11 
AnswerRe: Concatenation or Data Type problem :s Pin
Mbah Dhaim18-Sep-08 12:54
Mbah Dhaim18-Sep-08 12:54 
GeneralRe: Concatenation or Data Type problem :s Pin
Muammar©18-Sep-08 23:06
Muammar©18-Sep-08 23:06 
QuestionProblems connecting to excel with c# 2005 over windows2000 Pin
R.A.C18-Sep-08 10:05
R.A.C18-Sep-08 10:05 
AnswerRe: Problems connecting to excel with c# 2005 over windows2000 Pin
Paul Conrad18-Sep-08 10:27
professionalPaul Conrad18-Sep-08 10:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.