Groups > Databases > Access Databases and AccessDataSource Control > Re: SQL Not Working




SQL Not Working

SQL Not Working
Mon, 17 Mar 2008 20:31:36 +000
Hi,

I'm writing an aspx page which queries an access database. The SQL is generated
by the aspx page depending on values passed to it in querystrings, it is rather
long and complex, so I won't post it. 

My SQL returns no hits when the page runs (although I'm confident there should
be hits). However if I dump my SQL string to the screen (using
Response.Write(strSQL)) and copy it, I can paste it into a query direct in
Access and get the hits that I would expect.

 Does anyone know why this would be. I would expect the same SQL to get the same
hits whether it is sent from a web page or executed within the database.

 

Rhanks

Jason
Post Reply
Re: SQL Not Working
Mon, 17 Mar 2008 20:40:42 +000
Not posting the offending SQL is an odd decision.  It means that anyone wanting
to help has to guess.  Perhaps you are using the wrong wildcard character?  It
should be % not *.
Post Reply
Re: SQL Not Working
Mon, 17 Mar 2008 20:44:51 +000
No Sql, no any clue what is happen on page and run directly on access, at least
you need to post the output sql string for us to look
Post Reply
Re: SQL Not Working
Mon, 17 Mar 2008 20:47:27 +000
OK guys, here's the SQL. I didn't hink it would make any difference as I have
shown it works when pasted directly into a query in Access. It's only when the
web page performs the query that nothing is returned.

 here it is

SELECT DISTINCTROW tITRs.sProjectid, tITRs.sModuleId, tITRs.sSystemId,
tITRs.sSubSystemId, tITRs.sDisciplineId, tITRs.sTagNoId, tITRs.sItemId,
tITRs.dITRDateCompleted, tITRs.bITRCompleted, tITRs.sITRLocation,
tITRs.sITRResponsibility, tITRs.dDateLastUpdated, tITRs.sLastChangedBy,
tITRs.bThirdPartyWitness,tITRs.sDisciplineId, tITRs.sCompanyID,
tITRs.dITRDateWitness, tProjects.sProjectDesc, tTagNos.bConstruct,
tTagNos.bDestruct, tTagNos.sTagNoDescription, tITRs.sCompanyID,
tModules.sModuleDescription, tSystems.sSystemDescription FROM ((((tITRs LEFT
JOIN tProjects ON tITRs.sProjectid = tProjects.sProjectId) LEFT JOIN tModules ON
(tITRs.sModuleId = tModules.sModuleId) AND (tITRs.sProjectid =
tModules.sProjectId)) LEFT JOIN tSystems ON (tITRs.sSystemId =
tSystems.sSystemId) AND (tITRs.sModuleId = tSystems.sModuleId) AND
(tITRs.sProjectid = tSystems.sProjectId)) LEFT JOIN tTagNos ON tITRs.sTagNoId =
tTagNos.sTagNoId) LEFT JOIN tITRIds ON tITRs.sItemId = tITRIds.sITRId
WHERE(((tITRs.sProjectid) LIKE "*") And ((tITRs.sModuleId) Like
"*") And ((tITRs.sSystemId) Like "*") And
((tITRs.sSubSystemId) Like "*") And ((tITRs.sDisciplineId) Like
"*") And ((tITRs.sTagNoId) Like "*") And
((tITRs.sITRLocation) Like "*")) ORDER BY tITRs.sProjectid,
tITRs.sModuleId, tITRs.sSystemId, tITRs.sSubSystemId, tITRs.sDisciplineId,
tITRs.sTagNoId, tITRs.sItemId
Post Reply
Re: SQL Not Working
Mon, 17 Mar 2008 20:51:00 +000
curlydog:I didn't hink it would make any difference as I have shown it works
when pasted directly into a query in Access 

Wildcard characters.  My guess was right.  Change them from * to %.  Asterisks
work within Access, but the OleDb wildcard is %.
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact