![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi Mr., If you print @create_date to the screen, what exactly do you see? As a general rule, dates for Access need to be passed using #mm/dd/yyyy# format - including the # to identify it as a date. I am using access database in aspx. I did something like this : .... currParam = new oleDbParameter("@create_date", OleDbType.DBTimeStamp) currParam.value = Now cmd.parameters.add(currParam) In the sql I wrote : insert into mytable ( ... , create_date , ....) values( ..., @create_date, ...) When execute the query I get an error : Data type mismatch in criteria expression. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister http://www.mvps.org/word http://go.compuserve.com/MSOfficeForum This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#3
| |||
| |||
|
|
Hello, I am using access database in aspx. I did something like this : ... currParam = new oleDbParameter("@create_date", OleDbType.DBTimeStamp) currParam.value = Now cmd.parameters.add(currParam) In the sql I wrote : insert into mytable ( ... , create_date , ....) values( ..., @create_date, ...) When execute the query I get an error : Data type mismatch in criteria expression. What is the problem ? Thanks ![]() |
#4
| |||
| |||
|
|
First, you are using the @ symbol for param names, and in Access, I don't think that'll work for you --- you need to use the ? insert into mytable(..., create_date, ...) values (?, ?, ?) check out this link here, he goes into the whole process, but I think that's the main problem. Also, you can just use a DateTime field instead of Timestamp unless your db field is marked as such. Let me know if you have any problems. Bill "Mr. x" <a@b.com> wrote in message news:OcRBGnzbDHA.2024 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hello, I am using access database in aspx. I did something like this : ... currParam = new oleDbParameter("@create_date", OleDbType.DBTimeStamp) currParam.value = Now cmd.parameters.add(currParam) In the sql I wrote : insert into mytable ( ... , create_date , ....) values( ..., @create_date, ...) When execute the query I get an error : Data type mismatch in criteria expression. What is the problem ? Thanks ![]() |
#5
| |||
| |||
|
Thanks ![]() Now it's clear. The name after the insert ( ....) value (@par1, ...) par1 for parameter 1 - the name is ignored by the asp interperter, so I can use @xyz and it has the same result. (It doesn't seem to be the parameter currParam = new oldDBParameter("@xyz", OleDBType.Date) The thing that what is metter is the order of the paramerter and not what I called it at the insert command. I don't know why can I write any name I like after @ in the insert command - maybe it is for another purpose - I would like to know for what ? And suppose I don't want to use ? instead, but the name of the parameter itself - can I do it ? Thanks ![]() "William Ryan" <dotnetguru (AT) nospam (DOT) comcast.net> wrote in message news:#6jf0B9bDHA.1044 (AT) TK2MSFTNGP10 (DOT) phx.gbl... First, you are using the @ symbol for param names, and in Access, I don't think that'll work for you --- you need to use the ? insert into mytable(..., create_date, ...) values (?, ?, ?) check out this link here, he goes into the whole process, but I think that's the main problem. Also, you can just use a DateTime field instead of Timestamp unless your db field is marked as such. Let me know if you have any problems. Bill "Mr. x" <a@b.com> wrote in message news:OcRBGnzbDHA.2024 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hello, I am using access database in aspx. I did something like this : ... currParam = new oleDbParameter("@create_date", OleDbType.DBTimeStamp) currParam.value = Now cmd.parameters.add(currParam) In the sql I wrote : insert into mytable ( ... , create_date , ....) values( ..., @create_date, ...) When execute the query I get an error : Data type mismatch in criteria expression. What is the problem ? Thanks ![]() |
#6
| |||
| |||
|
|
Since you can't name the parameters if you use the ?, then order is absolutely critical. With named params, it doesn't matter, but if you don't have them, it's critical. So, did this fix your problem or is it still happening? Let me know Bill "Mr. x" <a@b.com> wrote in message news:#tXuCN#bDHA.3748 (AT) TK2MSFTNGP11 (DOT) phx.gbl... Thanks ![]() Now it's clear. The name after the insert ( ....) value (@par1, ...) par1 for parameter 1 - the name is ignored by the asp interperter, so I can use @xyz and it has the same result. (It doesn't seem to be the parameter currParam = new oldDBParameter("@xyz", OleDBType.Date) The thing that what is metter is the order of the paramerter and not what I called it at the insert command. I don't know why can I write any name I like after @ in the insert command - maybe it is for another purpose - I would like to know for what ? And suppose I don't want to use ? instead, but the name of the parameter itself - can I do it ? Thanks ![]() "William Ryan" <dotnetguru (AT) nospam (DOT) comcast.net> wrote in message news:#6jf0B9bDHA.1044 (AT) TK2MSFTNGP10 (DOT) phx.gbl... First, you are using the @ symbol for param names, and in Access, I don't think that'll work for you --- you need to use the ? insert into mytable(..., create_date, ...) values (?, ?, ?) check out this link here, he goes into the whole process, but I think that's the main problem. Also, you can just use a DateTime field instead of Timestamp unless your db field is marked as such. Let me know if you have any problems. Bill "Mr. x" <a@b.com> wrote in message news:OcRBGnzbDHA.2024 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Hello, I am using access database in aspx. I did something like this : ... currParam = new oleDbParameter("@create_date", OleDbType.DBTimeStamp) currParam.value = Now cmd.parameters.add(currParam) In the sql I wrote : insert into mytable ( ... , create_date , ....) values( ..., @create_date, ...) When execute the query I get an error : Data type mismatch in criteria expression. What is the problem ? Thanks ![]() |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |