Data mismatch in criteria expression
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Data mismatch in criteria expression

  1. #1
    Join Date
    Sep 2012
    Posts
    16

    Data mismatch in criteria expression

    I am using INSERT statement to execute the program. And the error has occured : "Data mismatch in criteria expression". I am checking my database but I could not find the error. Can you help me to fix the program.

    I am appreciate for your help!!!!!
    Attached Files Attached Files
    Last edited by thedeathnotes210x; November 13th, 2012 at 10:24 PM.

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Data mismatch in criteria expression

    Well a quick look at the Proggy i did notice this...

    Code:
    con.Execute "INSERT INTO tbl_item_detail VALUES ('" & rs("MaxField") + 1 & "','" & ws.Range("C" & i).Value & "','" & ws.Range("A" & i).Value & "','" & ws.Range("D" & i).Value & "','" & ws.Range("E" & i).Value & "','" & ws.Range("F" & i).Value & "','" & ws.Range("G" & i).Value & "','" & ws.Range("H" & i).Value & "','" & ws.Range("I" & i).Value & "','" & ws.Range("J" & i).Value & "','" & ws.Range("K" & i).Value & "','" & ws.Range("L" & i).Value & "','" & ws.Range("M" & i).Value & "','" & ws.Range("N" & i).Value & "','" & ws.Range("O" & i).Value & "','" & ws.Range("P" & i).Value & "','" & ws.Range("Q" & i).Value & "','" & ws.Range("R" & i).Value & "','" & ws.Range("S" & i).Value & "','" & ws.Range("T" & i).Value & "','" & ws.Range("U" & i).Value & "','" & ws.Range("V" & i).Value & "','" & ws.Range("W" & i).Value & "','" & ws.Range("X" & i).Value & "','" & ws.Range("Y" & i).Value & "','" & ws.Range("Z" & i).Value & "','" _
    & ws.Range("AA" & i).Value & "','" & ws.Range("AB" & i).Value & "','" & ws.Range("AC" & i).Value & "','" & ws.Range("AD" & i).Value & "','" & ws.Range("AE" & i).Value & "','" & ws.Range("AF" & i).Value & "','" & "-1" & "','" & tenUser & "','" & NgayGioDangNhap & "')"
    con1.Execute "INSERT INTO tbl_supplier(materialgroup,[desc]) VALUES ('" & ws.Range("A" & i).Value & "','" & ws.Range("B" & i).Value & "')"
    Now the sample Excel sheet included, has a problem with some of those Ranges...

    IE: Column J, M, AC, AD (row 7) & AE (row 7) all have calculations in them and not Actual Values, These could be the source of your problem.....

    Now the columns that have been defined as number in access need to receive a (Unformated) number before the insert will work.. So dont use ' on the numbers, because it designates Strings/Text.... Remove all number formatting including Currency/Weight/ Volume marks so that 2 413.98 cm3 is passed as 2413.98 <- NOTE: Not even a space is allowed.

    Sort out these two problems and you should be able to complete the SQL insert command....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center