Dim editdate As Date editdate = DTPEDITAT.Value Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE = (%" & editdate & "%)ORDER BY EMP_NAME ASC"
But it shows error 'Incorrect Syntax near ""'




Posted 02 February 2013 - 02:02 AM
Dim editdate As Date editdate = DTPEDITAT.Value Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE = (%" & editdate & "%)ORDER BY EMP_NAME ASC"
Posted 02 February 2013 - 03:35 AM
Dim editdate As Date editdate = DTPEDITAT.Value Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE LIKE %" & editdate.value & "% ORDER BY EMP_NAME ASC"
This post has been edited by <aris>: 02 February 2013 - 03:49 AM
Posted 12 March 2013 - 02:22 AM
<aris>, on 02 February 2013 - 03:35 AM, said:
Dim editdate As Date editdate = DTPEDITAT.Value Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE LIKE %" & editdate.value & "% ORDER BY EMP_NAME ASC"
Posted 12 March 2013 - 03:22 AM
Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
getConnect()
Dim editdate As Date
editdate = DTPEDITAT.Value.Date
MessageBox.Show(editdate)
Try
Conn.Open()
Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE LIKE %" & editdate & "% ORDER BY EMP_NAME ASC"
Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, Conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "ATTENDANCE")
Dim dt As DataTable = ds.Tables("ATTENDANCE")
Dim row As DataRow
Dim atstat As String
For Each row In dt.Rows
If row("AT_STATUS") = 1 Then
atstat = "Present"
ElseIf row("AT_STATUS") = 0 Then
atstat = "Absent"
ElseIf row("AT_STATUS") = 0.5 Then
atstat = "Halfday"
Else
atstat = "Error"
End If
For x As Integer = 0 To ATCEDITGRID.Rows.Count - 1
ATCEDITGRID.Rows(x).Cells(2).Value = row("EMP_ID")
ATCEDITGRID.Rows(x).Cells(3).Value = row("EMP_NAME")
ATCEDITGRID.Rows(x).Cells(0).Value = atstat
ATCEDITGRID.Rows(x).Cells(1).Value = row("AT_REMARK")
Next x
Next row
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Posted 12 March 2013 - 04:06 AM
Posted 12 March 2013 - 06:49 AM
Posted 12 March 2013 - 06:56 AM
Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
getConnect()
Dim editdate As Date
editdate = DTPEDITAT.Value.Date
MessageBox.Show(editdate)
Try
Conn.Open()
Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE LIKE %" & editdate & "% ORDER BY EMP_NAME ASC"
messagebox.show(strSQL)
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
getConnect()
Dim editdate As Date
editdate = DTPEDITAT.Value.Date
MessageBox.Show(editdate)
Try
Conn.Open()
Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_Date = '" & datetimepicker.value & "' ORDER BY EMP_NAME ASC"
messagebox.show(strSQL)
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Posted 12 March 2013 - 06:58 AM
Posted 14 March 2013 - 01:49 AM
harrybow5, on 12 March 2013 - 06:56 AM, said:
Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
getConnect()
Dim editdate As Date
editdate = DTPEDITAT.Value.Date
MessageBox.Show(editdate)
Try
Conn.Open()
Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE LIKE %" & editdate & "% ORDER BY EMP_NAME ASC"
messagebox.show(strSQL)
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
getConnect()
Dim editdate As Date
editdate = DTPEDITAT.Value.Date
MessageBox.Show(editdate)
Try
Conn.Open()
Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_Date = '" & datetimepicker.value & "' ORDER BY EMP_NAME ASC"
messagebox.show(strSQL)
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Posted 14 March 2013 - 04:30 AM
Posted 16 March 2013 - 02:43 AM
Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
ATCEDITGRID.Rows.Clear()
getConnect()
Dim editdate As String
DTPEDITAT.Value = Format(DTPEDITAT.Value, "dd/MM/yyyy")
editdate = DTPEDITAT.Value
Try
Conn.Open()
Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE = '" & editdate & "' ORDER BY EMP_NAME ASC"
Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, Conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "ATTENDANCE")
Dim dt As DataTable = ds.Tables("ATTENDANCE")
Dim row As DataRow
Dim atstat As String
For Each row In dt.Rows
If row("AT_STATUS") = 1 Then
atstat = "Present"
ElseIf row("AT_STATUS") = 0 Then
atstat = "Absent"
ElseIf row("AT_STATUS") = 0.5 Then
atstat = "Halfday"
Else
atstat = "Error"
End If
Me.ATCEDITGRID.Rows.Add(row("EMP_ID"), row("EMP_NAME"), atstat, row("AT_REMARK"))
Next row
ATCEDITGRID.TopLeftHeaderCell.Value = "Sr.No."
Me.ATCEDITGRID.RowHeadersDefaultCellStyle.Padding = New Padding(3)
ATCEDITGRID.AllowUserToAddRows = False
AddRowHeadersEdit()
Conn.Close()
Catch ex As SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
