Re: System.Data.SqlClient.SqlException: Subquery returned more than 1 value.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Try modifying yor Sub:
> 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)
response.write strSQL
response.end
> cmd.Connection.Open()
> cmd.ExecuteNonQuery()
> conn.Close()
> End Sub

Copy the result and run it in your database.

"Rod" <1gandalf@xxxxxxxxxxxxxxxx> wrote in message
news:%23RRkgMIXFHA.3584@xxxxxxxxxxxxxxxxxxxxxxx
>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
>
> Any help would be greatly appreciated.
>
> Rod.
>
>


.



Relevant Pages

  • Re: Emailing a Report
    ... CTRL-G to Goto the debuG window -- look at the SQL statement ... The Sub LoopAgmtsSendEmail is highlighted by the Debugger. ...
    (microsoft.public.access.modulesdaovba)
  • Re: System.Data.SqlClient.SqlException: Subquery returned more than 1 value.
    ... >> Private Sub executeSQL(strSQL as String) ... >> Dim conn As New System.Data.SqlClient.SqlConnection ... >> The site is using SQL Server 7. ...
    (microsoft.public.inetserver.asp.db)
  • Re: On Close -- use UnLoad, debug.print
    ... Building on to what Fred gave you, I have use line continuation sysmbols _ and assigned your SQL to a string so that you can debug it ... If you have problems after you run it, open the Debug window ... CTRL-G to Goto the debuG window -- look at the SQL statement ... Private Sub Form_Close ...
    (microsoft.public.access.formscoding)
  • Excel Problem
    ... I am basically trying to get data from an SQL database, ... Dim data As Worksheet, para As Worksheet ... Private Sub CommandButton1_Click ... if I put a more simple SQL statement in it to just ...
    (microsoft.public.excel.programming)
  • Re: Simple Insert Into...
    ... it is in a control on the form; and is unbound (it's actually a combo ... box that is used as a dropdown list, values taken from a different table; SQL ... I need this value to assign a unique ID to the entire recordset being ... In your form's Sub, you'll wind up with something like the following: ...
    (microsoft.public.access.modulesdaovba)