Conversion from type 'DBNull' to type 'Double' is not valid

user3966883

In my code I understand query getting null values and it throws this error. But since my query is little complex I don't understand how do I check for null values and avoid this error. Please help me to correct this query.

SELECT (SUM(charges) + SUM(behaviour) + SUM(admission) + SUM(properInformation) + SUM(hygine) + SUM(treatment))/(count(doctorID) * 6) AverageRating, COUNT(ID) RatingCount from ratings where doctorID = '" + doctorID + "'
Joachim Isaksson

If you want the query to not return NULL, you can just surround the expression with IFNULL to convert a possible NULL to 0, something like;

SELECT IFNULL((SUM(charges) + SUM(behaviour) + SUM(admission) + 
               SUM(properInformation) + SUM(hygine) + SUM(treatment))
              /(count(doctorID) * 6), 0) AverageRating, 
       COUNT(ID) RatingCount 
FROM ratings 
WHERE doctorID = '" + doctorID + "'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Conversion from type 'DBNull' to type 'String' is not valid

From Dev

Conversion from type 'DBNull' to type 'String' is not valid

From Dev

Conversion from type 'DBNull' to type 'Double' is not valid when returns empty data

From Dev

How to handle Conversion from type 'DBNull' to type 'Integer' is not valid

From Dev

Conversion from type 'DBNull' to type 'String' is not valid vb.net

From Dev

Conversion from type 'DBNull' to type 'Date' is not valid on tryparse

From Dev

Another "conversion from type DBNull to type Date not valid" issue

From Dev

Conversion from string to type Double is not valid

From Dev

Error: Conversion from string "" to type 'Double' is not valid

From Dev

Conversion from string to type Double is not valid

From Dev

Conversion from type 'DBNull' to type 'String' is not valid when inserting data from datagridview to sql database

From Dev

Conversion from type 'DBNull' to type 'String' is not valid when inserting data from datagridview to sql database

From Dev

"Conversion from string to type Double is not valid" error VB.NET

From Dev

Conversion from string "" to type 'Double' is not valid In .NET Fiddle's VB

From Dev

Conversion from string "X.X" to type 'Double' is not valid

From Dev

How to get rid of Conversion from string "admin" to type 'Double' is not valid

From Dev

Conversion from type 'Button' to type string is not valid

From Dev

Conversion from type 'Button' to type string is not valid

From Dev

Conversion from string "." to type 'Decimal' is not valid

From Dev

Conversion From String To Type 'Date' Is Not Valid

From Dev

Conversion from string "I" to type 'Boolean' is not valid

From Dev

Conversion from "string" to Type 'Boolean' is not valid

From Dev

Conversion From String To Type 'Date' Is Not Valid

From Dev

Conversion from string "0-1" to type 'Double' is not valid error : VB.net

From Dev

Need Help : Conversion from string "RS201504170001" to type 'Double' is not valid

From Dev

Behind the scenes of Visual Basic casting - Conversion from string to type 'Double' is not valid

From Dev

Conversion from String to type Double is not valid when calculating min and max values

From Dev

Additional information: Conversion from string "" to type 'Double' is not valid. Vb.net

From Dev

Type conversion in Java (Double / double)

Related Related

  1. 1

    Conversion from type 'DBNull' to type 'String' is not valid

  2. 2

    Conversion from type 'DBNull' to type 'String' is not valid

  3. 3

    Conversion from type 'DBNull' to type 'Double' is not valid when returns empty data

  4. 4

    How to handle Conversion from type 'DBNull' to type 'Integer' is not valid

  5. 5

    Conversion from type 'DBNull' to type 'String' is not valid vb.net

  6. 6

    Conversion from type 'DBNull' to type 'Date' is not valid on tryparse

  7. 7

    Another "conversion from type DBNull to type Date not valid" issue

  8. 8

    Conversion from string to type Double is not valid

  9. 9

    Error: Conversion from string "" to type 'Double' is not valid

  10. 10

    Conversion from string to type Double is not valid

  11. 11

    Conversion from type 'DBNull' to type 'String' is not valid when inserting data from datagridview to sql database

  12. 12

    Conversion from type 'DBNull' to type 'String' is not valid when inserting data from datagridview to sql database

  13. 13

    "Conversion from string to type Double is not valid" error VB.NET

  14. 14

    Conversion from string "" to type 'Double' is not valid In .NET Fiddle's VB

  15. 15

    Conversion from string "X.X" to type 'Double' is not valid

  16. 16

    How to get rid of Conversion from string "admin" to type 'Double' is not valid

  17. 17

    Conversion from type 'Button' to type string is not valid

  18. 18

    Conversion from type 'Button' to type string is not valid

  19. 19

    Conversion from string "." to type 'Decimal' is not valid

  20. 20

    Conversion From String To Type 'Date' Is Not Valid

  21. 21

    Conversion from string "I" to type 'Boolean' is not valid

  22. 22

    Conversion from "string" to Type 'Boolean' is not valid

  23. 23

    Conversion From String To Type 'Date' Is Not Valid

  24. 24

    Conversion from string "0-1" to type 'Double' is not valid error : VB.net

  25. 25

    Need Help : Conversion from string "RS201504170001" to type 'Double' is not valid

  26. 26

    Behind the scenes of Visual Basic casting - Conversion from string to type 'Double' is not valid

  27. 27

    Conversion from String to type Double is not valid when calculating min and max values

  28. 28

    Additional information: Conversion from string "" to type 'Double' is not valid. Vb.net

  29. 29

    Type conversion in Java (Double / double)

HotTag

Archive