SQL versus Access code

Results 1 to 2 of 2

Thread: SQL versus Access code

  1. #1
    Join Date
    Dec 1969

    Default SQL versus Access code

    I&#039ve been playing with some Access databases lately.<BR>But I keep running into "mismatch type" errors in the code, because most code seems to be written for SQL, not Access.<BR><BR>Anyone know of a good resource explaining code differences to use between Access and SQl databases?

  2. #2
    SQL <> SQL Serv Guest

    Default RE: SQL *SERVER* versus Access code

    SQL is a language. You use it to make queries versus almost any database. Incudling Access. And SQL Server. Which is another MS database product.<BR><BR>Now that we&#039ve cleared that up...<BR><BR>Generally, a SQL query (including INSERT, SELECT, UPDATE, DELETE, etc.) should work about the same against almost any database. But there is at least one place where Access is weird:<BR><BR>When you use a Date field in Access, the literal value you pass in your SQL must be enclosed in #...#, whereas in any other database I&#039ve seen you simply enclose the date in &#039...&#039 as you would any text field. So if you have an example not written for Access that uses date fields, indeed you would get "type mismatch" errors on literal date values.<BR><BR>So change code such as:<BR><BR>SQL = "INSERT INTO table (name,signupDate) VALUES(&#039" _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& Request("Name") & "&#039,&#039" & Request("theDate") & "&#039)"<BR><BR>into something like this:<BR><BR>SQL = "INSERT INTO table (name,signupDate) VALUES(&#039" _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& Request("Name") & "&#039,#" & Request("theDate") & "#)"<BR><BR>Other than that, if you find odd things that don&#039t work, try posting the code here. I&#039d bet that there are only a few other weirdnesses lurking in the background to bite you. Ehhhh...but I could be wrong.<BR><BR>

Posting Permissions

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