Results 1 to 2 of 2

Thread: Double Tables in Querrying Crystal Report

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Double Tables in Querrying Crystal Report

    Code:
    SqlConnection conn = new SqlConnection(cVar.conString);
                conn.Open();
                SqlCommand comm = conn.CreateCommand();
    
                comm.CommandText = "SELECT * FROM tblData WHERE RACK_NO = '" + cboRackNo.Text + "' AND CALENDERED_DATE BETWEEN  '" + dtpFrom.Text + "' AND '" + dtpTo.Text + "' ORDER BY CALENDERED_DATE DESC";
                cVar.dataReader = comm.ExecuteReader();
    
                try
                {
                    if (cVar.dataReader.HasRows)
                    {
                        cVar.dataReader.Close();
                        SqlDataAdapter da = new SqlDataAdapter(comm);
                        DataTable dt = new DataTable();
                        da.Fill(dt);
    
                        crChart_Thickness cChart_Thickness = new crChart_Thickness();
    
    cChart_Thickness.SetDataSource(dt);
                                            
                        frmPrintPreview fPrintPreview = new frmPrintPreview();
    
                        fPrintPreview.crystalReportViewer1.ReportSource = cChart_Thickness;
                        fPrintPreview.ShowDialog();
    above code will show the graph of the data in the given querry in tblData.
    but i have also added the table name "tblStandard" which created directly in the crystal report "Running Total" by getting the MAX and MIN value. the line graph is like this: example below is a graph

    1. MAX
    2. Data
    3. MIN

    if i use only table no problem bu if use 2 tables it will ask for database password? my question is how could pass the database password both
    tblData and tblStandard?

    tnx
    *****************
    VB6,PHP,VS 2005

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: Double Tables in Querrying Crystal Report

    disregard my questions i just put the code after the creating new chart
    and it works for the 2 tables.
    Code:
     Database crDatabase = cChart_Thickness.Database;
                        Tables crTables = crDatabase.Tables;
    
                        ConnectionInfo crConnInfo = new ConnectionInfo();
    
                        crConnInfo.ServerName = ".\\SQLEXPRESS";
                        crConnInfo.DatabaseName = "database";
                        crConnInfo.UserID = "user";
                        crConnInfo.Password = "password";
    
                        foreach (Table crTable in crTables)
                        {
                            TableLogOnInfo crLogOnInfo = crTable.LogOnInfo;
                            crLogOnInfo.ConnectionInfo = crConnInfo;
                            crTable.ApplyLogOnInfo(crLogOnInfo);
                        }
    *****************
    VB6,PHP,VS 2005

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width