Skip to content
Loading
  • +1
    Msg 156, Level 15, State 1, Procedure SpGetEmployee, Line 15 [Batch Start Line 0]
    Incorrect syntax near the keyword 'AND'.
    +1
  • Sachin Singh
    +1
    Yes AND is not needed it is typo
    1. create procedure SpGetEmployee      
    2. @searchText Varchar(500)=''      
    3. as      
    4. begin      
    5.       
    6. select * from       
    7.  tbl_Employee e       
    8. JOIN     
    9.  tbl_CheckIn ci     
    10. ON  e.Id=ci.EmpId      
    11. JOIN      
    12.  tbl_CheckOut co     
    13. ON co.EmpId=e.Id      
    14. where       
    15.  1 = (      
    16. CASE      
    17. WHEN (      
    18. @searchText IS NULL      
    19. OR LEN(@searchText) <= 0      
    20. )      
    21. THEN 1      
    22. ELSE (      
    23. CASE      
    24. WHEN (      
    25. (CAST(e.Id AS VARCHAR(50)) LIKE '%' + @searchText + '%')      
    26.       
    27. OR (EmpName LIKE '%' + @searchText + '%')      
    28.       
    29.       
    30. )      
    31. THEN 1      
    32. ELSE 0      
    33. END      
    34. )      
    35. END      
    36. )      
    37.       
    38. end      
     
    +1
  • +1
    1. private void BtnTimteIn_Click(object sender, EventArgs e)  
    2.        {  
    3.            try  
    4.            {  
    5.   
    6.                SqlConnection connection = new SqlConnection(myconn);  
    7.                connection.Open();  
    8.                SqlCommand cmd = new SqlCommand("spCheckIn", connection);  
    9.                cmd.CommandType = CommandType.StoredProcedure;  
    10.                cmd.Parameters.AddWithValue("@ActionType", "SaveData");  
    11.                cmd.Parameters.AddWithValue("@CheckIn", DateTime.Parse(dtpTimeIn.Text));  
    12.                  
    13.                int NumRes = cmd.ExecuteNonQuery();  
    14.                if (NumRes > 0)  
    15.                {  
    16.                    MessageBox.Show("Record Saved Successfully !!!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Information);  
    17.                    ClearAllData();  
    18.                }  
    19.                else  
    20.                {  
    21.                    MessageBox.Show("Please Try Again !!!");  
    22.                }  
    23.                connection.Close();  
    24.            }  
    25.            catch (Exception ex)  
    26.            {  
    27.                MessageBox.Show("Error:- " + ex.Message);  
    28.            }  
    29.              
    30.        }  
    +1