SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MS SQL:Insert Command error message

    Hi,
    i have a command object for an insert. But keep getting this error message.


    [Microsoft][ODBC SQL Server Driver][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

    Now if i run the command for the first time and it does an insert into my db, it works fine.

    However subsequent times, it gives the error message above.

    what could be wrong here ?
    thanks
    Afrika


    here is my code


    Code:
    set create_sms_history = Server.CreateObject("ADODB.Command")
    create_sms_history.ActiveConnection = MM_mary_STRING
    create_sms_history.CommandText = "dbo.insert_sms_history_1"
    create_sms_history.Parameters.Append create_sms_history.CreateParameter("@RETURN_VALUE", 3, 4)
    create_sms_history.Parameters.Append create_sms_history.CreateParameter("@senderID", 200, 1,20,create_sms_history__senderID)
    create_sms_history.Parameters.Append create_sms_history.CreateParameter("@Receipient", 200, 1,20,create_sms_history__Receipient)
    create_sms_history.Parameters.Append create_sms_history.CreateParameter("@Username", 200, 1,20,create_sms_history__Username)
    create_sms_history.Parameters.Append create_sms_history.CreateParameter("@message", 200, 1,200,create_sms_history__message)
    create_sms_history.Parameters.Append create_sms_history.CreateParameter("@IP", 200, 1,25,create_sms_history__IP)
    create_sms_history.CommandType = 4
    create_sms_history.CommandTimeout = 0
    create_sms_history.Prepared = true
    create_sms_history.Execute()

  2. #2
    SitePoint Addict danfran's Avatar
    Join Date
    Jan 2005
    Location
    New York City
    Posts
    244
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= ...
    We don't need to see the ASP, we need to see the SQL..

    A subquery is something like this:
    Code:
    select * 
    from table 
    where AccountBalance < (select MonthAmount from Balances where Month = 12)
    An example of a subquery that did what yours did (produce an error) is this:
    Code:
    select * 
    from table 
    where AccountBalance < (select MonthAmount from Balances)
    The subquery (in dark red), will produce more than 1 record, causing the error that you're probably getting. The query just doesn't make sense anymore. That's all SQL Server is saying.

    -Dan

  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dan, but wasnt the problem
    Aparently it was a trigger error.

    Solved it, thanks Anyway

    Afrika


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •