Connecting Tech Pros Worldwide Forums | Help | Site Map

deleting primary key

Familiar Sight
 
Join Date: Jul 2007
Location: United Kingdom
Posts: 203
#1: Aug 5 '09
i'm trying to delete the value from Access DB but the problem is following

Expand|Select|Wrap|Line Numbers
  1. Error Type:
  2. Microsoft JET Database Engine (0x80040E07)
  3. Data type mismatch in criteria expression.
  4.  
the id is primary key & auto number .

Expand|Select|Wrap|Line Numbers
  1. ors.open "select * from str where id='" & a & "'",ocon,adOpenDynamic,adLockOptimistic
any body know where the problem gonna be ?

GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 143
#2: Aug 5 '09

re: deleting primary key


Hi there,

Without knowing your DB I would hazard a guess at this:

Expand|Select|Wrap|Line Numbers
  1. where id='" & a & "'"
  2.  
Is your id field textual in nature?

If not:

Expand|Select|Wrap|Line Numbers
  1. where id=" & a
  2.  
Gaz
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#3: Aug 7 '09

re: deleting primary key


Gaz is right, let me clarify just in case it wasn't obvious. If you are sending text to access you need to enclose it in single quotes (Select * from BytesUsers where username = 'jhardman') but if you are sending a number you cannot use quotes (select * from BytesUsers where ID = 4321)

Jared
Reply