c# Operand type clash: date is incompatible with int

Hamidi Abdelhakim

When I execute the following query, I get the error message date is incompatible with int:

textBox4.Text = dateTimePicker1.Value.ToShortDateString();

DataSet ds1 = new DataSet();

cmd.CommandText = "select ID_REPAS FROM CONSOMMER C , GROUPE G WHERE G.REF_GROUPE=C.REF_GROUPE AND C.dateEFF=G.dateEff and G.REF_GROUPE=" + textBox3.Text + "and C.dateEFF=" +dateTimePicker1.Value.ToShortDateString();
da2.Fill(ds1, "idrepas");

textBox2.Text = ds1.Tables["idrepas"].Rows[0][0].ToString();
MikeDub

Clearest and safest way is to use SQL parameters...

cmd.CommandText = "select ID_REPAS FROM CONSOMMER C , GROUPE G WHERE G.REF_GROUPE=C.REF_GROUPE AND C.dateEFF=G.dateEff and G.REF_GROUPE=@txtBox3Val and C.dateEFF=@shortDate";

command.Parameters.Add(new SqlParameter("txtBox3Val" , textBox3.Text));
command.Parameters.Add(new SqlParameter("shortDate", dateTimePicker1.Value.ToShortDateString());

Which helps to avoid hard to manage tack ('+') together code and prevents injections attacks.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Operand type clash: date is incompatible with int in dateadd

From Dev

Tsql Operand type clash: date is incompatible with int

From Dev

Sql Server Operand type clash: date is incompatible with int

From Dev

Sql Server Operand type clash: date is incompatible with int

From Dev

Stored Procedure Operand type clash: date is incompatible with int

From Dev

Operand type clash: text is incompatible with uniqueidentifier

From Dev

Operand type clash: text is incompatible with uniqueidentifier

From Dev

Operand type clash: bigint is incompatible with time

From Dev

Operand type clash geography is incompatible with float

From Dev

Operand type clash: nvarchar is incompatible with Type_WP_Days

From Dev

Operand type clash: nvarchar is incompatible with Type_WP_Days

From Dev

Getting error:Operand type clash: nvarchar is incompatible with image

From Dev

NHibernate component mapping: Operand type clash: bigint is incompatible with time

From Dev

Error: operand types are incompatible ("int" and "const char*") c++

From Dev

Incompatible operand types Die and Int

From Dev

Table type parameter in a stored procedure cause operand type clash error

From Dev

Incompatible operand types between K and int Java

From Dev

incompatible operand types r.integer and int

From Dev

Argument of type "int" is incompatible with parameter of type "int *"

From Dev

Operand Data Type Clash when executing sp_help_job via VB.Net

From Dev

C - Incompatible Pointer Type

From Dev

incompatible type C error?

From Dev

TypeError: unsupported operand type(s) for +=: 'int' and 'list'

From Dev

unsupported operand type(s) for +: 'NoneType' and 'int'

From Dev

Unsupported operand type(s) for +: 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

From Dev

Unsupported operand type(s) for /: 'unicode' and 'int'

From Dev

TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

From Dev

TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

Related Related

  1. 1

    Operand type clash: date is incompatible with int in dateadd

  2. 2

    Tsql Operand type clash: date is incompatible with int

  3. 3

    Sql Server Operand type clash: date is incompatible with int

  4. 4

    Sql Server Operand type clash: date is incompatible with int

  5. 5

    Stored Procedure Operand type clash: date is incompatible with int

  6. 6

    Operand type clash: text is incompatible with uniqueidentifier

  7. 7

    Operand type clash: text is incompatible with uniqueidentifier

  8. 8

    Operand type clash: bigint is incompatible with time

  9. 9

    Operand type clash geography is incompatible with float

  10. 10

    Operand type clash: nvarchar is incompatible with Type_WP_Days

  11. 11

    Operand type clash: nvarchar is incompatible with Type_WP_Days

  12. 12

    Getting error:Operand type clash: nvarchar is incompatible with image

  13. 13

    NHibernate component mapping: Operand type clash: bigint is incompatible with time

  14. 14

    Error: operand types are incompatible ("int" and "const char*") c++

  15. 15

    Incompatible operand types Die and Int

  16. 16

    Table type parameter in a stored procedure cause operand type clash error

  17. 17

    Incompatible operand types between K and int Java

  18. 18

    incompatible operand types r.integer and int

  19. 19

    Argument of type "int" is incompatible with parameter of type "int *"

  20. 20

    Operand Data Type Clash when executing sp_help_job via VB.Net

  21. 21

    C - Incompatible Pointer Type

  22. 22

    incompatible type C error?

  23. 23

    TypeError: unsupported operand type(s) for +=: 'int' and 'list'

  24. 24

    unsupported operand type(s) for +: 'NoneType' and 'int'

  25. 25

    Unsupported operand type(s) for +: 'int' and 'str'

  26. 26

    TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

  27. 27

    Unsupported operand type(s) for /: 'unicode' and 'int'

  28. 28

    TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

  29. 29

    TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

HotTag

Archive