Click here to Skip to main content
15,911,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
i am working with Crystal Report with Vb.Net i got the Error like as below
" SQL Expression Can Not Be Used In Report".
VB
Dim rpttitle As String = "All Data Of Employee"
      Dim rptcomment As String
      con = New SqlConnection("Data Source=192.168.101.102;Initial Catalog=test_data;Persist Security Info=True;User ID=wml;Password=win")
      con.Open()

      'cmd = New SqlCommand("select * from test where dt ='" & Format(CType(DateTimePicker1.Text, Date), "MM/dd/yyyy") & "' , con)
      'cmd.ExecuteNonQuery()

      adpt = New SqlDataAdapter("select * from test where dt between'" & Format(CType(DateTimePicker1.Text, Date), "MM/dd/yyyy") & "'and '" & Format(CType(DateTimePicker2.Text, Date), "MM/dd/yyyy") & "' order by dt", con)
      ds = New Data.DataSet
      adpt.Fill(ds)

      If ds.Tables(0).Rows.Count > 0 Then

          Dim strRptName As String = "D:\Dipak Nakum\Fil_Pipe_Calculator\Fil_Pipe_Calculator\WindowsApplication1\reports\Report1.rpt"
          rptcomment = "Date Between " & Format(CType(DateTimePicker1.Text, Date), "dd/MM/yyyy") & " And " & Format(CType(DateTimePicker2.Text, Date), "dd/MM/yyyy")
          rpt.Load(strRptName)
          rpt.SetDatabaseLogon("wml", "win")
          rpt.SetDataSource(ds.Tables(0))
          rpt.SummaryInfo.ReportTitle = rpttitle
          rpt.SummaryInfo.ReportComments = rptcomment
          CrystalReportViewer1.ReportSource = rpt


end if

end sub

in the dataset which ever is output i want is i got in the dataset . i have done debugging deelpy bu t i don't found any error till last line, there is no any error comes till last line , then after above error was shown.
Posted
Updated 1-Apr-12 18:35pm
v2
Comments
Maciej Los 3-Apr-12 14:25pm    
In which line you got this error?

Did you try to formulas to select records using dates ranges? Examples:
1) on Codeproject[^] site,
2) on kenhamady[^] site
Dipak V Nakum 4-Apr-12 2:13am    
i had written clearly Dear "in the dataset which ever is output i want is i got in the dataset . i have done debugging deelpy bu t i don't found any error till last line, there is no any error comes till last line , then after above error was shown".
Dipak V Nakum 12-Apr-12 5:54am    
No any error is found

1 solution

Just give the full path of particular reports with the parent drive also.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900