Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2006, 12:22 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL IN

Does anyone know the exact query for IN in the following senario...

I want to search for 2 columns for 1 mobile number (mobile, alternate mobile)

I am using the following query


Code:
strSQL = "select * from tblcontest where bar_mob_no IN('" & sSQL &"') or bar_alt_mob in('" & sSQL &"')"
But its hshowing the following error
Code:
Microsoft JET Database Engine- Error '80040e14'

Syntax error (missing operator) in query expression 'bar_mob_no IN(''44444444'') or bar_alt_mob in(''44444444'')'.
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
__________________
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old October 30th, 2006, 07:31 AM
Authorized User
 
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code has been tested and it is working.
The query is correct.
There is no error in your code while using IN.
 
Old October 30th, 2006, 02:21 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You do have a problem. Your sSQL variable appears to contain a value that is enclosed in single quotes which results in an extra set of enclosing single quotes in your query.
You must only have one set of single quotes in your generated sql string.

The result from the error message:
Code:
bar_mob_no IN(''44444444'') or bar_alt_mob in(''44444444'')
What you want generated in your strSql:
Code:
bar_mob_no IN('44444444') or bar_alt_mob in('44444444')
Of course, that is assuming that the data type for bar_mob_no is some kind of text and not numeric. If you are using a numeric data type you don't want the single quotes at all.



Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
How Run .sql Script file in MS SQL Server 2000? aarkaycee SQL Server 2000 5 October 12th, 2009 05:43 AM
creating ssis packagte for sql server to sql serer Laxmikant_it ASP.NET 3.5 Professionals 0 November 26th, 2008 12:23 AM
Converting from MS SQL 2005 to Sql Epress edition saif44 SQL Language 0 February 16th, 2007 04:17 PM
Failed to copy objects from SQL server to SQL Serv monfu SQL Server 2000 4 December 4th, 2005 05:54 PM
Move SQL DB from one sql to another sql server Israr SQL Server 2000 3 January 24th, 2005 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.