|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Data type mismatch in criteria expression.
Hi.
I am trying to make a page where you can view orders which customers have placed, I have already made several of these pages, however they were viewing the customers and products. The problem ii have is that i have made a dynamic drop down box on the first page which has the name "make" and it has the action set to "res_1_orders_2.asp", which is the page i am having trouble with. i have made a recordset which has a filter of "Request.Form("make"): 10 <% 11 Dim Recordset1 12 Dim Recordset1_numRows 13 14 Set Recordset1 = Server.CreateObject("ADODB.Recordset") 15 Recordset1.ActiveConnection = MM_fgh_STRING 16 Recordset1.Source = "SELECT * FROM Query WHERE Order_Date = '" + Replace(Recordset1__MMColParam, "'", "''") + "' ORDER BY Surname ASC" 17 Recordset1.CursorType = 0 18 Recordset1.CursorLocation = 2 19 Recordset1.LockType = 1 20 Recordset1.Open() 21 Recordset1_numRows = 0 22 %> When I run the first page, selecting a date, and click "submit" the second page comes up, showing this: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E07) [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. /splatware/res_1_view_orders_2.asp, line 20 At the moment Line 20 is "Recordset1.Open()" I cant see a problem of this. Can someone help and tell me whats wrong with the recordset? Thanks for any help, it is greately appreciated. Tyrone |
|
#2
|
||||
|
||||
|
It would appear that the SQL Statement (Dreamweaver generated?) is incorrect, when searching a date field in MS Access it requires (#) pound signs around the date like this
Code:
"SELECT * FROM Query WHERE Order_Date = #" & Recordset1__MMColParam & "# ORDER BY Surname ASC" I would strongly suggest in the future that you write your own code and not rely on dreamweaver to write it for you, as it makes many mistakes and is not very efficient. |
|
#3
|
|||
|
|||
|
Thanks, but still a problem! :(
Hi again,
Thanks for that...but theres still a problem. It doesn't come up with the error anymore, and the page loads. But now the drop down box doesnt list the customers that made an order on the date that you choose on the previous page, all the drop down box shows is ----------SELECT---------- which the default value is set to. I need it to take the input from the last drop down box, called "make" and show the customers that placed an order on that date. For every date on the page before (res_1_view_orser.asp) there is definetly an order, because of the way that i have done the page. so there must always be a name on the following page (the one with the problem "res_1_view_oreders_2.asp") This is what the recordset, including the request.form: <% Dim Recordset1__MMColParam Recordset1__MMColParam = "1" If (Request.Form("make") <> "") Then Recordset1__MMColParam = Request.Form("make") End If %> <% Dim Recordset1 Dim Recordset1_numRows Set Recordset1 = Server.CreateObject("ADODB.Recordset") Recordset1.ActiveConnection = MM_fgh_STRING Recordset1.Source = "SELECT * FROM Query WHERE Order_Date = #" & Recordset1__MMColParam & "# ORDER BY Surname ASC" Recordset1.CursorType = 0 Recordset1.CursorLocation = 2 Recordset1.LockType = 1 Recordset1.Open() Recordset1_numRows = 0 %> Can you help again Thanks for alot Tyrone |
|
#4
|
||||
|
||||
|
You code doesn't look correct.
Code:
Recordset1__MMColParam = Request.Form("make")
Recordset1.Source = "SELECT * FROM Query WHERE Order_Date = #" & Recordset1__MMColParam & "# ORDER BY Surname ASC"
You query is try to return records where the Order_Date = the make selected on the form??? Wouldn't it be like this? Code:
Recordset1__MMColParam = Request.Form("make")
Recordset1.Source = "SELECT * FROM Query WHERE Make = '" & Recordset1__MMColParam & "' ORDER BY Surname ASC"
|
|
#5
|
|||
|
|||
|
OMG! Another problem.
I have inserted what u showed, but now there is a problem with the "Recordset1.Open()" bit of the rocordset. When i run the page there is an error, and it says this:
Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /splatware/res_1_view_orders_2.asp, line 20 Here is line 20: <% Dim Recordset1 Dim Recordset1_numRows Set Recordset1 = Server.CreateObject("ADODB.Recordset") Recordset1.ActiveConnection = MM_fgh_STRING Recordset1.Source = "SELECT * FROM Query WHERE Make = '" & Recordset1__MMColParam & "' ORDER BY Surname ASC" Recordset1.CursorType = 0 Recordset1.CursorLocation = 2 Recordset1.LockType = 1 Recordset1.Open() Recordset1_numRows = 0 %> I have looked, and can't find any sort of problem with this. Thanks for your time Tyrone |
|
#6
|
|||
|
|||
|
i have a similar problem
Hi guys my code is like this
/weekly.asp?wd=05.04.2004&wdl=11.04.2004)<% dim mydatel mydatel=cdate(request.querystring("wdl")) %> <% dim mydate mydate=cdate(request.querystring("wd")) %> <% Dim rs_weekly Dim rs_weekly_numRows Set rs_weekly = Server.CreateObject("ADODB.Recordset") rs_weekly.ActiveConnection = MM_conn_STRING rs_weekly.Source = "SELECT * FROM reon_db_tbl1 WHERE a_date<='"&mydatel&"' AND a_datelast>='"&mydate&"'" rs_weekly.CursorType = 0 rs_weekly.CursorLocation = 2 rs_weekly.LockType = 1 rs_weekly.Open() rs_weekly_numRows = 0 %> error message is like this: Data type mismatch in criteria expression in the database is access2000, cols a_date and a_datelast are formated as short date which refers to 10.02.2000 in my language (Turkish) thanks for your interest. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Data type mismatch in criteria expression. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|