Last post Apr 12, 2017 09:23 AM by Eric Du
Apr 07, 2017 01:44 PM|bonhommesanon|LINK
I am trying to call selected records to my report but anytime I select with a predefined variable as my selection criteria a receive the entire table to the report but what I need are records who match my selection criteria.
Please take a look at my code.
Public Sub Today_Punches()
Dim Pass_Geter As New Pass_Geter
Dim tag As String
Dim Ds As New DataSet()
Dim tester As New streetDA
Dim Employee As String = "Emile Devere"
Dim Datum As String = "string"
Dim dateValue As Date
Dim Date_Day As String
Datum = "Mon, May 02, 16"
If Not IsPostBack Then
Dim dt As DataTable
Dim SQL As String = "SELECT Employee,Datum ,Punch_Type,Bracket FROM Today_punches where Today_punches.Datum = Datum"
Dim strConnString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Using conn As New SqlConnection(strConnString)
Using comm As New SqlCommand(SQL, conn)
Using da As New SqlDataAdapter(comm)
dt = New DataTable("tbl")
Dim _rdStudents As ReportDocument = New ReportDocument()
Dim reportPath As String = Server.MapPath("Company_Punches.rpt")
CrystalReportViewer1.ReportSource = _rdStudents
Apr 10, 2017 08:25 AM|Eric Du|LINK
According to the posted code, I tested it in myside, I hope you could try the following steps to remove issue:
1. Add a breakpoint at the begin of this function, check if have triggered this method(Today_Punches).
2. About this parameter(Datum) in SqlCommand, I think it is not the valid parameter. Please try the following methods to add parameter value:
Dim SQL As String = "SELECT Employee,Datum ,Punch_Type,Bracket FROM Today_punches where Today_punches.Datum = " + Datum
Using cmd As New MySqlCommand("SELECT Employee,Datum ,Punch_Type,Bracket FROM Today_punches where Today_punches.Datum =@Datum")
Apr 10, 2017 02:35 PM|bonhommesanon|LINK
Thanks for your answer, I think the first approach could be better suitable but by trying it I am getting an error message saying " Invalid Syntax near ' '.
Could you please let me know what that means
Apr 11, 2017 02:30 AM|Eric Du|LINK
According to this error message, I think this issue is caused by the SQL command, you need check if the fields exist in your database or your parameter value is a valid parameter.
Dim parameter As Integer = Convert.ToInt32(TextBox1.Text)
Dim dt As New DataTable()
Dim SQL As String = "SELECT * FROM Movies where Movies.ID = " + parameter
Sample structure of the SQL:
Apr 11, 2017 03:13 PM|bonhommesanon|LINK
Thanks Eric for your help. I got it to work by adding some extra. Take a look
Dim SQL As String = "SELECT Employee,Datum ,Punch_Type,Bracket FROM Today_punches where Today_punches.Datum ='" + Datum + "'"
Apr 12, 2017 09:23 AM|Eric Du|LINK
I am very glad to hear your problem has been solved. I hope you could mark your last replay as answer, this will better help someone who meet the same problem as you!