Ask a Question related to ASP Database, Design and Development.
-
Christopher Brandsdal #1
Type mismatch in Date
Hi!
I have a problem with my vbscript code...
my database is a access 2000 db.
here is the code Im running:
----------------------------------------------------------------------------
----------------------------
sqlBetal = "SELECT * FROM Faktura WHERE FakturaNR=" &
Request.QueryString("FakturaNR")
Set rsBetal = Server.CreateObject("ADODB.Recordset")
rsBetal.Open sqlBetal, conn, 3, 3
rsBetal("Betalt") = True
rsBetal("BetaltSum") = Request.Form("BetaltSum")
rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
vbShortDate)
rsBetal.Update
rsBetal.close
Set rsBetal = Nothing
Response.Redirect "Faktura.asp"
----------------------------------------------------------------------------
----------------------------
I get this error:
----------------------------------------------------------------------------
----------------------------
Provider error '80020005'
Type mismatch.
/faktura/Faktura_betal.asp, line 45
----------------------------------------------------------------------------
----------------------------
line 45 looks kie this:
rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
vbShortDate)
The Request.Form("BetaltDato") has the <%=date()%> value.....
The BetaltDato field in the database is formated as Date/time
What could be wrong????
If I change it to: rsBetal("BetaltDato") = Date() the code runs
with outh problem..
So I tried this:
--<%= Date() %>--<%= FormatDateTime(Request.Form("BetaltDato"), vbShortDate)
%>--
The output looks like this:
--07.05.2004--07.05.2004--
ITS THE SAME!!!!! grr.... hehe
Any idea?????
Christopher Brandsdal
Christopher Brandsdal Guest
-
Type mismatch error
This query works fine on a live server using an MSSQL database: <cfquery name="qIndex" datasource="#appDSN#" username="shampoo"... -
Interface Type Mismatch
This works in Java, so it is not clear why Actionscript does not implement it the same way. If an instance of a class that implements an Interface... -
Type mismatch?
Hi i'm getting a type mismatch error, anyone tell me why pls? conn.Execute "DELETE FROM Bmemo WHERE (tDate <= '" & date() & "')" tDate is a... -
Type Mismatch
I'm at my wits end here. I am getting type mismatch error in a ASP page when I try to multiply decimals*integers. This shouldn't be this difficult.... -
Type Mismatch again
Hi, One page passes a strIssueNo to another, so on the 2nd page: Dim IssueNo IssueNo = Request.Item("strIssueNo") This 2nd page is designed... -
Cowboy #2
Re: Type mismatch in Date
Check if the date is null in the data that throws the error. You cannot
format a NULL to a date format (ToShortDate()).
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************
Think Outside the Box!
************************************************
"Christopher Brandsdal" <cwbrandsdal@c2i.net> wrote in message
news:%23mRe1YFNEHA.628@TK2MSFTNGP11.phx.gbl...--> Hi!
>
> I have a problem with my vbscript code...
> my database is a access 2000 db.
>
> here is the code Im running:
>
> ----------------------------------------------------------------------------> ----------------------------
> sqlBetal = "SELECT * FROM Faktura WHERE FakturaNR=" &
> Request.QueryString("FakturaNR")
> Set rsBetal = Server.CreateObject("ADODB.Recordset")
> rsBetal.Open sqlBetal, conn, 3, 3
> rsBetal("Betalt") = True
> rsBetal("BetaltSum") = Request.Form("BetaltSum")
> rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
> vbShortDate)
>
> rsBetal.Update
> rsBetal.close
> Set rsBetal = Nothing
> Response.Redirect "Faktura.asp"
> ----------------------------------------------------------------------------> ----------------------------
>
> I get this error:
>
> ----------------------------------------------------------------------------> ----------------------------
>
> Provider error '80020005'
>
> Type mismatch.
>
> /faktura/Faktura_betal.asp, line 45
>
> --------------------------------------------------------------------------vbShortDate)> ----------------------------
> line 45 looks kie this:
>
> rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
> vbShortDate)
>
> The Request.Form("BetaltDato") has the <%=date()%> value.....
>
> The BetaltDato field in the database is formated as Date/time
>
> What could be wrong????
>
> If I change it to: rsBetal("BetaltDato") = Date() the code runs
> with outh problem..
>
>
> So I tried this:
>
> --<%= Date() %>--<%= FormatDateTime(Request.Form("BetaltDato"),> %>--
>
> The output looks like this:
>
> --07.05.2004--07.05.2004--
>
> ITS THE SAME!!!!! grr.... hehe
>
> Any idea?????
>
>
> Christopher Brandsdal
>
>
Cowboy Guest
-
Bob Barrows [MVP] #3
Re: Type mismatch in Date
Christopher Brandsdal wrote:
--> Hi!
>
> I have a problem with my vbscript code...
> my database is a access 2000 db.
>
> here is the code Im running:
>
> --------------------------------------------------------------------------The initial problem is delimiters (or lack thereof).> ----------------------------
> sqlBetal = "SELECT * FROM Faktura WHERE FakturaNR=" &
> Request.QueryString("FakturaNR")
> Set rsBetal = Server.CreateObject("ADODB.Recordset")
> rsBetal.Open sqlBetal, conn, 3, 3
> rsBetal("Betalt") = True
> rsBetal("BetaltSum") = Request.Form("BetaltSum")
> rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
> vbShortDate)
The Date() and Now() functions return a Variant whose subtype is Date - no
delimiters are needed.
The FormatDateTime function is returns a Variant whose subtype is String
which is supposed to represent a date: a date "literal". Date literals must
be delimited by hash marks (#). So the initial solution is to do this:
sDate=FormatDateTime(Request.Form("BetaltDato"), vbShortDate)
rsBetal("BetaltDato") = "#" & sDate & "#"
However, the problem is deeper than that: your server's short date setting
is resulting in a non-ISO compliant date format. Dates should be entered in
databases in ISO format. With Access, the format should be YYYY-MM-DD. See
here for help in converting your date to the proper format (if you can't
figure out how to do it yourself, that is):
[url]http://www.aspfaq.com/show.asp?id=2260[/url].
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Bob Barrows [MVP] Guest
-
Aaron Bertrand - MVP #4
Re: Type mismatch in Date
A couple of issues. (a) are you using Request.Form or Request.QueryString?
(b) do not use ADODB.Recordset to perform UPDATEs. Use a single, atomic
statement. (c) always validate your input and make sure that the data is as
expected *before* sending it to the database. (d) never use vbShortDate,
since this setting can change. For Access, you should always use YYYY-MM-DD
for date values.
Taking (b) and (d) in mind only, how about:
dt = cdate(Request.Form("BetaltDato"))
dt = year(dt) & "-" & right("00" & month(dt), 2) & "-" & right("00" &
day(dt), 2)
SQL = "UPDATE Faktura SET Betalt=-1, BetaltSum=" & _
Request.Form("BetaltSum") & ", BetaltDato=#" & dt & "#" & _
" WHERE FakturaNR=" & Request.QueryString("FakturaNR")
conn.execute SQL, , 129
Better yet, Access can calculate the date() itself, so why bother running
into formatting issues and passing that extra data over the wire?
SQL = "UPDATE Faktura SET Betalt=-1, BetaltSum=" & _
Request.Form("BetaltSum") & ", BetaltDato=Date()" & _
" WHERE FakturaNR=" & Request.QueryString("FakturaNR")
conn.execute SQL, , 129
--
Aaron Bertrand
SQL Server MVP
[url]http://www.aspfaq.com/[/url]
"Christopher Brandsdal" <cwbrandsdal@c2i.net> wrote in message
news:#mRe1YFNEHA.628@TK2MSFTNGP11.phx.gbl...--> Hi!
>
> I have a problem with my vbscript code...
> my database is a access 2000 db.
>
> here is the code Im running:
>
> ----------------------------------------------------------------------------> ----------------------------
> sqlBetal = "SELECT * FROM Faktura WHERE FakturaNR=" &
> Request.QueryString("FakturaNR")
> Set rsBetal = Server.CreateObject("ADODB.Recordset")
> rsBetal.Open sqlBetal, conn, 3, 3
> rsBetal("Betalt") = True
> rsBetal("BetaltSum") = Request.Form("BetaltSum")
> rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
> vbShortDate)
>
> rsBetal.Update
> rsBetal.close
> Set rsBetal = Nothing
> Response.Redirect "Faktura.asp"
> ----------------------------------------------------------------------------> ----------------------------
>
> I get this error:
>
> ----------------------------------------------------------------------------> ----------------------------
>
> Provider error '80020005'
>
> Type mismatch.
>
> /faktura/Faktura_betal.asp, line 45
>
> --------------------------------------------------------------------------vbShortDate)> ----------------------------
> line 45 looks kie this:
>
> rsBetal("BetaltDato") = FormatDateTime(Request.Form("BetaltDato"),
> vbShortDate)
>
> The Request.Form("BetaltDato") has the <%=date()%> value.....
>
> The BetaltDato field in the database is formated as Date/time
>
> What could be wrong????
>
> If I change it to: rsBetal("BetaltDato") = Date() the code runs
> with outh problem..
>
>
> So I tried this:
>
> --<%= Date() %>--<%= FormatDateTime(Request.Form("BetaltDato"),> %>--
>
> The output looks like this:
>
> --07.05.2004--07.05.2004--
>
> ITS THE SAME!!!!! grr.... hehe
>
> Any idea?????
>
>
> Christopher Brandsdal
>
>
Aaron Bertrand - MVP Guest



Reply With Quote

