HighTechTalks DotNet Forums  

access database date parameter error

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss access database date parameter error in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mr. x
 
Posts: n/a

Default access database date parameter error - 08-30-2003 , 06:02 PM






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



Reply With Quote
  #2  
Old   
Mr. x
 
Posts: n/a

Default Re: access database date parameter error - 08-31-2003 , 05:24 AM






Thanks
This doen't work,
but I did paid attention to something strange, that may be the reason to the
problem :

I am trying doing the follow :
Insert into mytable(col1, col2, col3, col4, ... col10)
values(@par1, @par2, @par3, @par4, ... @par10)

I have notice that the row is not inserted as I wish to,
and columnt : col9 i.e is set to parameter : par5 (and not to par9
respectively).
And this is not the only column that is inserted not as the sql command is
asking to.

(colomns doesn't get the right parameters, even I change the order of the
columns and the parameters).

Why is this problem ?

Thanks

"Cindy Meister -WordMVP-" <CindyMeister (AT) swissonline (DOT) ch> wrote

Quote:
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 :-)




Reply With Quote
  #3  
Old   
William Ryan
 
Posts: n/a

Default Re: access database date parameter error - 08-31-2003 , 10:59 AM



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

Quote:
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





Reply With Quote
  #4  
Old   
Mr. x
 
Posts: n/a

Default Re: access database date parameter error - 08-31-2003 , 02:16 PM



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

Quote:
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







Reply With Quote
  #5  
Old   
William Ryan
 
Posts: n/a

Default Re: access database date parameter error - 08-31-2003 , 06:36 PM



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

Quote:
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









Reply With Quote
  #6  
Old   
Mr. x
 
Posts: n/a

Default Re: access database date parameter error - 09-01-2003 , 03:58 AM



Thanks
I see by the time of your massege that you spending nights in the internet -
thank you for any of your efforts.

I see that with named params or with ? the order is critical.
With named params - even a named that doesn't exists - aspx runs with no
problem, but the order is critical.

Anyway - everything works now, since I have paid attention to the order of
creation of the parameters.

Thanks

"William Ryan" <dotnetguru (AT) nospam (DOT) comcast.net> wrote

Quote:
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











Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.