locked
SELECT_case " to type 'Double' is not valid RRS feed

  • Question

  • User1977787504 posted
        
                    SQLProTemp = "SELECT	CASE " +
                                    +"WHEN VFT.IsActive=0 then VFT.TemplateName +' *' " +
                                    +"ELSE  VFT.TemplateName " +
                              +"END AS TemplateName,VFT.ID,'' AS Status " +
                        +"FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName "

    it is giving me the error
    SELECT case " to type 'Double' is not valid

    Tuesday, November 5, 2013 9:00 AM

Answers

  • User1079421601 posted

    Your code is ok. You can take a string variable and assign string to it. Then assing string variable to SQLProTem.

    Debug your code what you find in string variable execute in sql query editor. If it is ok. Then I think your code should be ok.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 5, 2013 10:49 AM
  • User-158764254 posted

    waqar1

    It is a solution, but If I write the query in one line is working fine also, but in multi line it is giving me error the same as before.

    since you're posting in the vb.net forum, we'll assume that's the language you're using.

    vb.net uses a line continuation character (an underscore character) for spanning single statements across multiple lines

    for example: http://msdn.microsoft.com/en-us/library/aa711641(v=vs.71).aspx

    Additionally, vb.net does support a few scenarios wher it can implicitly perform line continuation

    for example: http://msdn.microsoft.com/en-us/library/vstudio/865x40k4.aspx

    take smirnov's vb example and either add the explicit line continuation character, or reposition the & operators so they appear at the end of the individual lines.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 6, 2013 7:08 AM

All replies

  • User1508394307 posted

    I think that error occurred not on sql but somewhere else.

    What is the exact error message and the code where it is occurred?

    Tuesday, November 5, 2013 9:40 AM
  • User1977787504 posted

    I think that error occurred not on sql but somewhere else.

    What is the exact error message and the code where it is occurred?

    Nope,, I debugged it, it is giving error me on the Case keyword, i was from Csharp, i think there would be some conflict of VB.net keywords,
    but i tried .
    CASE,
    Case
    case,
    it giving the same error
    "SELECT case " to type 'Double' is not valid"


    Is it due to any Concatenate issue?

    Tuesday, November 5, 2013 10:30 AM
  • User1508394307 posted

    The query is absolutely ok. So, it might be only the way you create and call it.

    If it is a c#, you have too many ++

    Must be

    SQLProTemp = "SELECT CASE " 
    +"WHEN VFT.IsActive=0 then VFT.TemplateName +' *' " 
    +"ELSE  VFT.TemplateName " 
    +"END AS TemplateName,VFT.ID,'' AS Status " 
    +"FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName ";

    or

    SQLProTemp = @"SELECT CASE  
     WHEN VFT.IsActive=0 then VFT.TemplateName +' *'  
     ELSE  VFT.TemplateName  
     END AS TemplateName,VFT.ID,'' AS Status  
     FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName ";

    If it is vb, then use & insead of +

    SQLProTemp = "SELECT CASE " 
    & "WHEN VFT.IsActive=0 then VFT.TemplateName +' *' " 
    & "ELSE  VFT.TemplateName " 
    & "END AS TemplateName,VFT.ID,'' AS Status " 
    & "FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName "
    Tuesday, November 5, 2013 10:37 AM
  • User1079421601 posted

    Your code is ok. You can take a string variable and assign string to it. Then assing string variable to SQLProTem.

    Debug your code what you find in string variable execute in sql query editor. If it is ok. Then I think your code should be ok.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 5, 2013 10:49 AM
  • User1977787504 posted

    The query is absolutely ok. So, it might be only the way you create and call it.
    If it is a c#, you have too many ++
    Must be
    SQLProTemp = "SELECT CASE "
    +"WHEN VFT.IsActive=0 then VFT.TemplateName +' *' "
    +"ELSE  VFT.TemplateName "
    +"END AS TemplateName,VFT.ID,'' AS Status "
    +"FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName ";

    or

    SQLProTemp = @"SELECT CASE WHEN VFT.IsActive=0 then VFT.TemplateName +' *' ELSE VFT.TemplateName END AS TemplateName,VFT.ID,'' AS Status FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName ";

    If it is vb, then use & insead of +

    SQLProTemp = "SELECT CASE " & "WHEN VFT.IsActive=0 then VFT.TemplateName +' *' " & "ELSE VFT.TemplateName " & "END AS TemplateName,VFT.ID,'' AS Status " & "FROM V_FileTemplates VFT WHERE VFT.FileType= 1 ORDER BY VFT.TemplateName "

    It is not working,

    Wednesday, November 6, 2013 1:11 AM
  • User1977787504 posted

    Your code is ok. You can take a string variable and assign string to it. Then assing string variable to SQLProTem.

    Debug your code what you find in string variable execute in sql query editor. If it is ok. Then I think your code should be ok.

    It is a solution, but If I write the query in one line is working fine also, but in multi line it is giving me error the same as before.

    Wednesday, November 6, 2013 1:12 AM
  • User1508394307 posted

    It is not working,

    What is not working?

    Wednesday, November 6, 2013 1:46 AM
  • User-158764254 posted

    waqar1

    It is a solution, but If I write the query in one line is working fine also, but in multi line it is giving me error the same as before.

    since you're posting in the vb.net forum, we'll assume that's the language you're using.

    vb.net uses a line continuation character (an underscore character) for spanning single statements across multiple lines

    for example: http://msdn.microsoft.com/en-us/library/aa711641(v=vs.71).aspx

    Additionally, vb.net does support a few scenarios wher it can implicitly perform line continuation

    for example: http://msdn.microsoft.com/en-us/library/vstudio/865x40k4.aspx

    take smirnov's vb example and either add the explicit line continuation character, or reposition the & operators so they appear at the end of the individual lines.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 6, 2013 7:08 AM