remove this line
//This is where I am having a problem
ClientFileRepository repository = new ClientFileRepository();
Main Topics
Browse All TopicsHello!
I am new to development of any kind and I have what I think is a scope problem but I do not know how to fix it.
What I am trying to do:
The page in question (FileUpload.aspx) is a page that allows a user to upload a file to a folder. I am trying to capture the fileid (scope_identity) and username (of the user logged in) (I have done this). The next part is to use the username as a parameter for a stored proc that will return the guid for the username value.
After I have both the fileid and the userid (guid), I need to run an insert stored proc that inputs both to a linking table. This table has an id pk, userid, fileid.
Where I am stuck:
I had help in setting this next part up and I really do not yet fully understand everything that is happening here (at least not enough to really trouble shoot). What I have is another page (ClientFileRepository.aspx
At this point I am in over my head...I thought I needed them together because each returns a value I need to insert into a table. I am at a loss as to how this should be rewritten so that I can grab both values and insert them into my table. I assume this will require yet another method which will just complicate the matter further.
Can anyone tell me what I am doing wrong? Any help would be appreciated!!
Thanks,
AJ
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You are declaring "ClientFileRepository repository" two times in the same scope at Line numbers 49 and 55.
Both these lines are in the same scope i.e. within the same pair of curly brackets. {}
The two declarations confuse the compiler, that's why it generates the error. The compiler finds that you have already declared a variable of the same name before.
So you have two options to solve the error
1. Remove the statement at line 55
2. Change the statement at line 55 to
repository = new ClientFileRepository();
This will cause the object created at line 49 to be disposed and made available for Garbage collection. The variable will now point to a new object at line 55.
But looking at the flow of the code, this will not give you the expected results.
So my opinion is to go with the first option. Remove line 55.
Business Accounts
Answer for Membership
by: CyrexCore2kPosted on 2008-10-14 at 21:00:43ID: 22717997
Change
ClientFileRepository repository = new ClientFileRepository();
to
repository = new ClientFileRepository();