Re: System.Data.SqlClient.SqlException: Subquery returned more than 1 value.
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Thu, 19 May 2005 11:10:11 -0400
There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-savvy person here who can
answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
However, I'll take a stab at it (I've just started using .Net)
Rod wrote:
> I have a client site where the code below has been working happily
> for at least four months. Last week an error appeared related to the
> following SQL statement.
>
> The site is using SQL Server 7. The code is ASP.NET
>
> An example of the SQL statement is:
>
> INSERT INTO OrderItems (ClientID, ProductID, OrderHeaderID, Quantity,
> Dispatched, BackOrdered) SELECT ClientID, ProductID, 1371 AS
> OrderHeaderID, Quantity, Dispatched, BackOrdered FROM Basket WHERE
> RequisitionID = 1369
>
> The error message is:
>
> System.Data.SqlClient.SqlException: Subquery returned more than 1
> value. This is not permitted when the subquery follows =, !=, <, <= ,
> >, >= or when the subquery is used as an expression...
>
> There appears to be nothing wrong with the SQL Statement, indeed if
> run in Query Analyser it executes correctly. I cannot see how the
> error message relates to the code at all. Nor do I understand why
> the code worked for four months and has not decided to fail.
>
> The context in which the code is called is the procedure below where
> the SQL statement is passed to the parameter strSQL.
>
> Private Sub executeSQL(strSQL as String)
> Dim conn As New System.Data.SqlClient.SqlConnection(CONN_STRING)
> Dim cmd As New System.Data.SqlClient.SqlCommand(strSQL, conn)
> cmd.Connection.Open()
> cmd.ExecuteNonQuery()
> conn.Close()
> End Sub
>
Well, you're right. This error seems to be totally unrelated to this
statement. There is no subquery here.
Is the error reproducible? Try using SQL Profiler to trace what's actually
happening.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Follow-Ups:
- References:
- Prev by Date: System.Data.SqlClient.SqlException: Subquery returned more than 1 value.
- Next by Date: Re: 80004005 Unspecified Error
- Previous by thread: System.Data.SqlClient.SqlException: Subquery returned more than 1 value.
- Next by thread: Re: System.Data.SqlClient.SqlException: Subquery returned more than 1 value.
- Index(es):
Relevant Pages
|