Help!

Discussion in 'Databases' started by JEP_Dude, Feb 9, 2010.

  1. #1
    Hello...

    I'm new with using SQL with VS 2008. I like to think that I'm getting better, but I've run into what I hope is only a slight problem.

    What does and how can I fix the following error message?

    "The variable name'@ClosePrice' has already been declared. Variable names must be unique within a query batch or stored procedure."

    I'm suspicious that their may be another version of this DB elsewhere. If that is the cause of this error, how should I track it down and remove it?

    May you have a blessed day as the Lord wills.

    JEP_Dude
     
    JEP_Dude, Feb 9, 2010 IP
  2. RonBrown

    RonBrown Well-Known Member

    Messages:
    934
    Likes Received:
    55
    Best Answers:
    4
    Trophy Points:
    105
    #2
    It's pretty much exactly what it says. It doesn't have anything to do with another database.

    You have a variable called @ClosePrice. It is being used somewhere in a query or stored procedure. That variable is then being declared again, so the error is being displayed.

    Check your code and the stored procedure for all instances of the variable "@ClosePrice" and you will find the error. It should be relatively easy to find.
     
    RonBrown, Feb 10, 2010 IP
  3. vunder

    vunder Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Feel free to paste a snippet and we just might be able to help.
     
    vunder, Feb 11, 2010 IP
  4. halo636

    halo636 Peon

    Messages:
    59
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As Ron mentioned above it pretty much just means it is being used elsewhere already.
     
    halo636, Feb 13, 2010 IP
  5. JEP_Dude

    JEP_Dude Peon

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey there....

    I did a search for "@Clos" as I wanted to see ALL POSSIBLE COMBINATION. However, it returned, "Search found no results". I couldn't find it! What should I try next? I'm out of ideas!

    God bless

    JEP_Dude
     
    JEP_Dude, Feb 13, 2010 IP
  6. JEP_Dude

    JEP_Dude Peon

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hey there...

    There is some hope! I did a "Find and Replace" search for "@ClosePrice". I told it to "Look in:" "Entire Solution". It stated that this was found in an ".XSD" file. What type of file is ".XSD"?

    I looked at the line with the mysterious variable name. It was ....

    <CommandText>
    INSERT INTO [dbo].[Statistics] ([PrimaryKey], [Symbol], ..... , [ClosePrice]) VALUES (@PrimaryKey, @Symbol, .... , @ClosePrice);
    SELECT PrimaryKey, Symbol, .... , ClosePrice
    FROM [Statistics]
    WHERE (PrimaryKey = @PrimaryKey)
    </CommandText>

    Why did VS.Net 2008 insert the "@" symbol in the VALUES clause? ...and why did it flag it as an error? Did I miss something here? Could there be another name for this column in the SQL table definition? If there is, how should I go back and fix it?

    Sorry for all these Q's but this is the first time I'm using SQL and the first time I'm trying to design a website. So please help this newbie.

    May you have a blessed day as the Lord wills.

    JEP_Dude
     
    JEP_Dude, Feb 13, 2010 IP