Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Data type mismatch in criteria expression

Data type mismatch in criteria expression

Scheduled Pinned Locked Moved ASP.NET
databasedesigndockerhelpquestion
8 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    frossie
    wrote on last edited by
    #1

    i keep having runtime errors everytime i try to update my database in the datalist. Can someone pls help me rectify them? aspx. file this is in the EditItemTemplate of the datalist control. <%#DataBinder.Eval(Container.DataItem, "ID")%> <%#DataBinder.Eval(Container.DataItem, "checklist_Item")%> aspx.vb file Sub MyDataList_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles MyDataList.UpdateCommand Dim tbox As TextBox Dim ID As String 'Dim txtEventDate, txtEventTrigger As Date 'Dim ID, txtEventDate, txtEventTrigger As String Dim txtEventDate, txtEventTrigger '---retrieves the key for the row--- ID = MyDataList.DataKeys(e.Item.ItemIndex) 'MsgBox("1") '---find the textbox control containing the title tbox = CType(e.Item.FindControl("txtEventDate"), TextBox) txtEventDate = tbox.Text 'MsgBox("2") '---find the textbox control containing the price tbox = CType(e.Item.FindControl("txtEventTrigger"), TextBox) txtEventTrigger = tbox.Text 'MsgBox("3") '---updates the database--- Dim sql As String = "UPDATE programs SET date_Completed='" + txtEventDate + "' , date_Trigger='" + txtEventTrigger + "' WHERE ID='" + ID + "'" Dim comm As New OleDbC

    M 1 Reply Last reply
    0
    • F frossie

      i keep having runtime errors everytime i try to update my database in the datalist. Can someone pls help me rectify them? aspx. file this is in the EditItemTemplate of the datalist control. <%#DataBinder.Eval(Container.DataItem, "ID")%> <%#DataBinder.Eval(Container.DataItem, "checklist_Item")%> aspx.vb file Sub MyDataList_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles MyDataList.UpdateCommand Dim tbox As TextBox Dim ID As String 'Dim txtEventDate, txtEventTrigger As Date 'Dim ID, txtEventDate, txtEventTrigger As String Dim txtEventDate, txtEventTrigger '---retrieves the key for the row--- ID = MyDataList.DataKeys(e.Item.ItemIndex) 'MsgBox("1") '---find the textbox control containing the title tbox = CType(e.Item.FindControl("txtEventDate"), TextBox) txtEventDate = tbox.Text 'MsgBox("2") '---find the textbox control containing the price tbox = CType(e.Item.FindControl("txtEventTrigger"), TextBox) txtEventTrigger = tbox.Text 'MsgBox("3") '---updates the database--- Dim sql As String = "UPDATE programs SET date_Completed='" + txtEventDate + "' , date_Trigger='" + txtEventTrigger + "' WHERE ID='" + ID + "'" Dim comm As New OleDbC

      M Offline
      M Offline
      manowj
      wrote on last edited by
      #2

      Hi, The Error might be [Datatype in the database must be numeric and you are assigning a string to it], If your database is ms-access use "#" for the date columns.

      F 1 Reply Last reply
      0
      • M manowj

        Hi, The Error might be [Datatype in the database must be numeric and you are assigning a string to it], If your database is ms-access use "#" for the date columns.

        F Offline
        F Offline
        frossie
        wrote on last edited by
        #3

        can you show me an example code to put in access or the codefile? becos i don really get what u say.

        frossie

        _ M 2 Replies Last reply
        0
        • F frossie

          can you show me an example code to put in access or the codefile? becos i don really get what u say.

          frossie

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #4

          You can check the query which you are generating, check that query by executing it in backend first.

          Best Regards, Apurva Kaushal

          1 Reply Last reply
          0
          • F frossie

            can you show me an example code to put in access or the codefile? becos i don really get what u say.

            frossie

            M Offline
            M Offline
            manowj
            wrote on last edited by
            #5

            Hi, check this out, (1) "UPDATE programs SET date_Completed=#" + txtEventDate + "# , date_Trigger=#" + txtEventTrigger + "# WHERE ID='" + ID + "'" (2) "UPDATE programs SET date_Completed=#" + txtEventDate + "# , date_Trigger=#" + txtEventTrigger + "# WHERE ID=" + ID for (1) provided [date_completed is date, date_trigger is date and ID is string] in database for (2) provided [date_completed is date, date_trigger is date and ID is numeric] in database display this query string in ur browser and copy paste in database, run it out and check.

            F 1 Reply Last reply
            0
            • M manowj

              Hi, check this out, (1) "UPDATE programs SET date_Completed=#" + txtEventDate + "# , date_Trigger=#" + txtEventTrigger + "# WHERE ID='" + ID + "'" (2) "UPDATE programs SET date_Completed=#" + txtEventDate + "# , date_Trigger=#" + txtEventTrigger + "# WHERE ID=" + ID for (1) provided [date_completed is date, date_trigger is date and ID is string] in database for (2) provided [date_completed is date, date_trigger is date and ID is numeric] in database display this query string in ur browser and copy paste in database, run it out and check.

              F Offline
              F Offline
              frossie
              wrote on last edited by
              #6

              ok thanks alot. it finally solved that problem.

              frossie

              F 1 Reply Last reply
              0
              • F frossie

                ok thanks alot. it finally solved that problem.

                frossie

                F Offline
                F Offline
                frossie
                wrote on last edited by
                #7

                If (ID = 2) Then TextBox1.Text = ds.Tables("programs").Rows(ID).Item(2) Dim temp1 As New DateTime(Year(TextBox1.Text), Month(TextBox1.Text), Day(TextBox1.Text)) MsgBox("temp1=" + temp1) temp1 = temp1.AddDays(7) ds.Tables("programs").Rows(ID + 1).Item(3) = temp1 End If i keep getting this error "Object reference not set to an instance of an object". Why isit so?

                frossie

                _ 1 Reply Last reply
                0
                • F frossie

                  If (ID = 2) Then TextBox1.Text = ds.Tables("programs").Rows(ID).Item(2) Dim temp1 As New DateTime(Year(TextBox1.Text), Month(TextBox1.Text), Day(TextBox1.Text)) MsgBox("temp1=" + temp1) temp1 = temp1.AddDays(7) ds.Tables("programs").Rows(ID + 1).Item(3) = temp1 End If i keep getting this error "Object reference not set to an instance of an object". Why isit so?

                  frossie

                  _ Offline
                  _ Offline
                  _AK_
                  wrote on last edited by
                  #8

                  Which line you get the error? Check whether that object exists or not.

                  Best Regards, Apurva Kaushal

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups