Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

heya can someone help ..

 

i am using vb.net in my aspx.vb file i am writing code with SQL

 

i keep on getting an error message say the CAST expects AS

 

thanks in advance sonia

 

 

" SELECT Mobile.Label + ' ( ' + Mobile.Registration + ' / ' + CAST(CAN_Message.Locator_ID AS varchar(5)) + ' )' AS Vehicle," & _
                               " (cast (Cast(CAN_Message.Distance * "
       If Session("user_Miles") = True Then
           strSQL += "0.6214)as decimal(10,2)) as nvarchar) + 'm') as distance, "
       Else
           strSQL += "1.0000)as decimal(10,2)) as nvarchar) + 'km') as distance, "
       End If

       strSQL += _
                               " (cast (CAST(CAN_Message.Fuel_Consumption * "
       If Session("user_miles") = True Then
           strSQL += "4.546)as decimal(10,2)) as nvarchar) + 'gallons') as Fuel_Used, "
       Else
           strSQL += "22)as decimal(10,2))as nvarchar) + 'litres') as fuel_used ,"
       End If

       strSQL += _
                     " (cast (Cast(CAN_Message.Fuel_Consumption / CAN_Message.Distance / "
       If Session("user_Miles") = True Then
           strSQL += "1) as decimal(10,2)) as nvarchar) + ' mpg ')  as Consumption_Rate "
       Else
           strSQL += "100) as decimal(10,2)) as nvarchar) + ' lts/100km ') as  Consumption_Rate  "
       End If

       strSQL += _
                               " FROM CAN_Message INNER JOIN " & _
                               " Mobile ON CAN_Message.Locator_ID = Mobile.Mobile_ID " & _
                               " WHERE CAN_Message.Locator_Id IN (" & strMobileList & ") " & _
                               " AND CAN_Message.Creation_Date >=" & strSQLFromDateTime & " AND Creation_Date<=" & strSQLToDateTime & _
                               " GROUP BY Mobile.Label + ' ( ' + Mobile.Registration + ' / ' + CAST(CAN_Message.Locator_ID AS varchar(5)) + ' )' "

Posted

Hi sonia. . .

I think you have an extra '(' before some of the casts:

 

" (cast (Cast(CAN_Message.Distance * "

 

also

 

your group by statement is underqualified

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...