MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2003, 05:44 AM
m175400 m175400 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 19 m175400 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem with SELECT query with WHERE clause

For some reason since migrating to a MS SQL database the following always returns no results:

'Open a recorset to check whether or not filename is already in use

Dim objRS

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = MM_archantInsight_STRING
objRS.Source = "SELECT * FROM tblImages WHERE filename LIKE '" & filename & "'"
objRS.CursorType = 0
objRS.CursorLocation = 2
objRS.LockType = 1
objRS.Open

It's to check that there's not already an image with a given name in the database, but I know there is, yet still always returns objRS.recordcount = -1

This worked ok in Access, so I am at a loss.

Please help!

Reply With Quote
  #2  
Old October 25th, 2003, 06:11 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,801 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 14 h 25 sec
Reputation Power: 278
Try ... LIKE '%"&filename&"%'

Reply With Quote
  #3  
Old October 25th, 2003, 06:29 AM
m175400 m175400 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 19 m175400 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've actually managed to fix it now by using the following, as I had done with access before:

strSQL = "SELECT * FROM tblImages WHERE filename = '" & filename & "'"
Set objRS = Server.CreateObject("ADODB.RecordSet")objRS.Open strSQL, dbConn, 1,3

Thanks for your help!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Problem with SELECT query with WHERE clause


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway