Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 help with Date in SQL # '

Author  Topic 

jarv
Posting Yak Master

131 Posts

Posted - 2009-02-03 : 10:24:44
I get the error: Data type mismatch in criteria expression.

so, I added # instead of ' around the date and I still get the error?!
Please help


strSQL = "INSERT INTO tblFiles (FileName,FileSize,DateUploaded,UploadedBy,Filepath) Values ('"& Upload.UploadedFiles(fileKey).FileName &"',"& Upload.UploadedFiles(fileKey).Length &",#"& Now() & "#,""Admin"",'"& Upload.UploadedFiles(fileKey).FileName &"')"

adoCon.Execute(strSQL)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-03 : 10:32:01
check data type of each column and see if you're inserting only allowed value types.
Go to Top of Page

jarv
Posting Yak Master

131 Posts

Posted - 2009-02-03 : 10:44:45
i've debugged and everything seems ok?!

INSERT INTO tblFiles (FileName,FileSize,DateUploaded,UploadedBy,Filepath) Values ('index.html','312',#03/02/2009 15:46:47#,"Admin",'index.html')
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-03 : 12:22:34
what are datatypes of FileName,FileSize,DateUploaded,UploadedBy,Filepath?
Go to Top of Page

jarv
Posting Yak Master

131 Posts

Posted - 2009-02-04 : 08:31:53
data types?
Go to Top of Page

jarv
Posting Yak Master

131 Posts

Posted - 2009-02-04 : 08:33:07
you mean:

FileName = Text
FileSize = INT
DateUploaded = Date/Time
UploadedBy = Text
FilePath = Text
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-04 : 08:40:59
Check quotes around ADMIN text.
As of now, you are treating admin as a column, not as a value.

strSQL = "INSERT INTO tblFiles (FileName,FileSize,DateUploaded,UploadedBy,Filepath) Values ('"& Upload.UploadedFiles(fileKey).FileName &"',"& Upload.UploadedFiles(fileKey).Length &",#"& Now() & "#,"'Admin'",'"& Upload.UploadedFiles(fileKey).FileName &"')"
adoCon.Execute(strSQL)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

jarv
Posting Yak Master

131 Posts

Posted - 2009-02-04 : 08:45:23
I have been trying to insert text into an INT Data type

silly me!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-04 : 09:13:39
yup..i guessed. thats why i told to check them
Go to Top of Page
   

- Advertisement -