title: pass parameters on crystal report , connect access with code , vb.net
body: <p>I want to search clients that got to shop between two dates. 
  The code I use seems alright and it doesn't return any error but the CR returns everything - It does not use the date search function. The CR I use is tested with a simple program that open CR and works fine.
  database is ms access and code is in visual studio 2005</p>
  
  <p>The second issue I have is that despite i use the connection info part it still ask me for a code 
  PS. sorry for my bad formatting , i am new in stackoverflow and i find it hard to make a post 
  thank you!
  -Agisilaos</p>
  
  <pre><code>Imports CrystalDecisions.CrystalReports.Engine
  Imports CrystalDecisions.Shared
  Public Class Form1
      Dim crConnectionInfo As New ConnectionInfo()
  
  
   Private Sub Button1_Click(ByVal sender As System.Object, _
     ByVal e As System.EventArgs) Handles Button1.Click
  
     Dim cryRpt As New ReportDocument
  
  
  cryRpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument
          cryRpt.Load("C:\Users\agis\Documents\Visual Studio 2005\Projects\new_contracts     _of_month\new_contracts _of_month\CrystalReport2.rpt",     CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
  
  
  With crConnectionInfo
          .ServerName = "C:\Users\agis\Desktop\Insurance database\Insurancemanager.mdb"
          .UserID = "Admin"
          .Password = "kos"
          .DatabaseName = "insurancemanager"
      End With
  
       'first parameter
      Dim crParameterFieldDefinitions As ParameterFieldDefinitions
      Dim crParameterFieldDefinition As ParameterFieldDefinition
      Dim crParameterValues As New ParameterValues
      Dim crParameterDiscreteValue As New ParameterDiscreteValue
      crParameterDiscreteValue.Value = Convert.ToDateTime(TextBox1.Text) 
  
      crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
      crParameterFieldDefinition = crParameterFieldDefinitions.Item("startdate")
      crParameterValues = crParameterFieldDefinition.CurrentValues
      crParameterValues.Add(crParameterDiscreteValue)
      crParameterValues.Clear()
  
      ' second parameter : 
      Dim crParameterFieldDefinitions2 As ParameterFieldDefinitions
      Dim crParameterFieldDefinition2 As ParameterFieldDefinition
      Dim crParameterValues2 As New ParameterValues
      Dim crParameterDiscreteValue2 As New ParameterDiscreteValue
      crParameterDiscreteValue2.Value = Convert.ToDateTime(TextBox2.Text)
      TextBox3.Text += "   " + crParameterDiscreteValue2.Value 
      crParameterFieldDefinitions2 = cryRpt.DataDefinition.ParameterFields
      crParameterFieldDefinition2 = crParameterFieldDefinitions2.Item("enddate")
      crParameterValues2 = crParameterFieldDefinition2.CurrentValues
      crParameterValues2.Clear()
  
  
      crParameterValues2.Add(crParameterDiscreteValue2)
      crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
      crParameterFieldDefinition2.ApplyCurrentValues(crParameterValues2)
       CrystalReportViewer1.ReportSource = cryRpt
      CrystalReportViewer1.Refresh()
  End Sub
  
  
  
  
      End Class
  </code></pre>