473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SQL Statement in ASP.NET 2.0 page gives strange error!

Hello,

I have a search box on my web app that I want to search several tables in my
SQL 2000 DB. I have set up a full text catalog for indexing.

The following Select statement works perfectly but only searches from 1
table:

SELECT * FROM edl WHERE CONTAINS (*, @query)

This is great but it only searched one table not many tables.

So I changed the Select statement to this:

SELECT * FROM edl WHERE CONTAINS (*, @query) UNION SELECT * FROM autometer
WHERE CONTAINS (*, @query)

Now I get this error:

Exception Details: System.Data.SqlClient.SqlException: All queries in an SQL
statement containing a UNION operator must have an equal number of
expressions in their target lists.

Does anyone know what I am doing wrong? I did some research on the web and
found that the UNION operator would add to the result set but it does not
seem to be working.

Thanks,

washoetech

Nov 19 '05 #1
1 931
washoetech wrote:
Hello,

I have a search box on my web app that I want to search several
tables in my SQL 2000 DB. I have set up a full text catalog for
indexing.
The following Select statement works perfectly but only searches from
1 table:

SELECT * FROM edl WHERE CONTAINS (*, @query)

This is great but it only searched one table not many tables.

So I changed the Select statement to this:

SELECT * FROM edl WHERE CONTAINS (*, @query) UNION SELECT * FROM
autometer WHERE CONTAINS (*, @query)

Now I get this error:

Exception Details: System.Data.SqlClient.SqlException: All queries in
an SQL statement containing a UNION operator must have an equal
number of expressions in their target lists.

Does anyone know what I am doing wrong? I did some research on the
web and found that the UNION operator would add to the result set but
it does not seem to be working.

Thanks,

washoetech


a UNION returns the result as a single table, so the columns in the queries
*have* to contain the same columns. At least order & type *need* to be the same,
I'm not entirly sure about the actual *name* of the column, it's possible
that the name used in the first query is used.

Hans Kesting
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: ...
7
by: Paul | last post by:
I thought this is more of an IE issue but i've had no joy on that group perhaps somebody here will have a clue. If i click a link to a web page embedded in Excel (97 OR 2000) i get the standard...
6
by: Graeme Wood | last post by:
I have an ASP page hosted on a windows 2003 server. This page was working fine until Saturday. Now, the server doesn't serve it and gives a 404 page not found error. The file DEFINITELY exists...
1
by: Jurrie | last post by:
Hi all, I use apaches FOP to translate an XML-document into a PDF-document. I use repeatable-page-master-alternitives, but FOP gives some strange errors: Unsupported element encountered:...
3
by: Jack | last post by:
Hi, I have a asp confirmation page using a asp-sql statement that updates a database However, there are few text fields which when left empty gives error stating Access did not update field...
3
by: Jack | last post by:
Hi, I have a sql statement in asp page as below sql = " INSERT INTO tblExpense (ENO, EntryDate, ContractedServiceExpense, " sql = sql & "TravelExpense, PersonnelExpense)" sql = sql & "...
6
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file =...
6
by: Not4u | last post by:
Hello Config : SQL 2000 on WIN 2000 (IIS 5.0) In my ASP page for some queries i have this error : Microsoft OLE DB Provider for SQL Server error '80040e31' Timeout expired
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.