Need help

This is a discussion on "Need help" within the Databases section. This forum, and the thread "Need help are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 26th, 2005, 16:14
New Member
Join Date: Sep 2005
Location: Brazil
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to pablobhz Send a message via MSN to pablobhz Send a message via Yahoo to pablobhz
Need help

Hello.
I am tryng to connect to an SQL database...
in the page,it has to filter by "month and year"
i am getting the error

'800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

It points to line 23...i will show the code...
if someone can help me,i'll thank a lot

<%
caminho=left(Server.mappath(Request.ServerVariable s("PATH_INFO")),InstrRev(Server.mappath(Request.Se rverVariables("PATH_INFO")),"\"))
Dim ObjDB


Set ObjDB = Server.CreateObject("ADODB.Connection")
ObjDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&caminho&"relatorio\banco.mdb"
if request.form("mes") <> "" AND request.Form("ano") <> "" then
SQL = "SELECT banco.nome,banco.telefone,banco.mail,banco.dataabe rtura,banco.horaabertura,banco.datafechamento,banc o.horafechamento FROM chamado WHERE dataabertura = #"&month(mes) & "" &year(ano)&"# order by cod desc"
Response.Write("Nao foi possivel completar sua requisicao")
Response.End
end if
Set rsinf = Server.CreateObject("ADODB.Recordset")
rsinf.Open SQL, ObjDB ,adOpenStatic, adLockOptimistic, acCdmText(THIS IS THE LINE 23)


%>

Thanks.
Reply With Quote

  #2 (permalink)  
Old Sep 26th, 2005, 19:07
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
You can't make a valid date with just a month and year, a valid date will also have a day.

But you probably want everything for that month, not just on a specific day so you'll need to use some date functions in SQL to compare the month and year.

So
Code: Select all
WHERE dataabertura = #"&month(mes) & "" &year(ano)&"# order...
becomes

Code: Select all
WHERE datepart('m',dataabertura) = "&month(mes) & " AND datepart('yyyy',dataabertura) = " &year(ano)&" order...
Reply With Quote
Reply

Tags
help

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:25.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43