Just nu i M3-nätverket
Jump to content

problem med sql-sats välja specifik medlem AND max


John Schneider

Recommended Posts

John Schneider

Har ett problem på aspsidan. Sqlsatsen ser ut som följer:[log]SQLStmt1 = "SELECT * FROM cars WHERE memberid = "& member & " AND carid=(select max(carid) from cars where memberid =" & member[/log]

När jag skriver ut frågan (när jag själv är inloggad), ser den ut så här:

SELECT * FROM cars WHERE memberid = 23 AND carid=(select max(carid) from cars where memberid =23

 

när jag sedan försöker mig på att köra den uppstår ett fel jag inte förstår...[log]

<%

DIM action

action=request.QueryString("action")

member=Request.Cookies("UserID")("NR")

%>

 

<%

set connection = server.CreateObject("ADODB.connection")

connection.open session("DB")

 

SQLStmt1 = "SELECT * FROM cars WHERE memberid = "& member & " AND carid=(select max(carid) from cars where memberid =" & member

 

response.Write(SQLStmt1)

set rs1 = connection.execute(SQLStmt1)

response.Write(rs1("bil01"))

%>

[/log]

Felmeddelandet:

start-->

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

 

[Microsoft][ODBC Microsoft Access Driver] Missing ), ], or Item in query expression 'memberid = 23 AND carid=(select max(carid) from cars where memberid =23'.

 

/Childpage/internsidor/processIII.asp, line 15

<--slut

 

Rad 15 är connection.execute....

 

LOG-taggar tillagda av moderator

 

[inlägget ändrat 2007-08-14 22:06:22 av Cluster]

Link to comment
Share on other sites

Fattas en slutparantes.

 

SQLStmt1 = "SELECT * FROM cars WHERE memberid = "& member & " AND carid=(select max(carid) from cars where memberid =" & member & ")"

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...