Not connecting to database

assaultkitty
assaultkitty used Ask the Experts™
on
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Technology Ninja
Distinguished Expert 2018
Commented:
Hi assaultkitty,

I doubt if anyone would help you around here if you ask them to solve the entire application. You have to put in some efforts from your side. For example, at least open the project, try to understand how it works and then try to make it work. Then if you hit a roadblock then ask the question here.

If I were you, I will start looking in the web.config as generally that's where a connectionstring goes. Once you have figured out that part we can proceed further.

Also please try to understand, I do not intend to offend/insult you in any ways. I am trying to hep you understand how Experts-Exchange workss in general.

Regards,
Chinmay.

Author

Commented:
I wish you would read the question better.  I do not ask the experts to solve the program.  First I ask a specific question and give you what I have done.  Please do you job.  You are suppose to help in anyway with giving me the answer.

Author

Commented:
Mr. Patel, I would appreciate an example.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Hi assaultkitty,

You should not give points until your question has been answered. By policy, I never answer homework types of questions as it might not be helpful in a long run to the asker. I would rather explain the concept and fundamentals.

Tell you what, you ask me specific questions - Tell me where you are stuck and I will see to that I stick to this question till the end.

Also I saw another question; it seems you felt I am being mean to you and I am so sorry about it. It made me smile and sad at the same time. Generally I am mean when I answer to people who are not willing to put in efforts [but I know you have been putting efforts from your end, have seen your questions] but when I was replying my intention was to help you only. Let me explain a little more, when I was learning, my bosses had a policy, they'd let me take some extra time but they'd want me to figure out stuff on my own[I know I am a lucky man] and you know what in turn it became a rule in my company. We allowed developers to take some extra time before we jump in to help them and trust me 90% of those are guys are rockstars in their jobs today and while they didn't like us[at all] back then now they appreciate what we did.

So I see you have figured out connection part by other questions you have asked. Tell me what's next?

Tell me are you facing any exceptions? Let me know and I will answer here.

Again I apologize if you felt offended.

Regards,
Chinmay.

Author

Commented:
Yes,you did! I need to use the web configuration file to link up my access database.  this information led me to believe that I was completely on the wrong track.  So, I stand by my decision.  You are a little mean but I got you point!!! Thanks.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Alright. Let me explain.

You can put connection string in your code but best practice is to store the connectionstring in web.config.

If  you open the web.config file it has a dedicated section for connection strings <connectionStrings/>

If you hardcode the connectionstring biggest disadvantage is everytime you have to change it you have to recompile/redploy your project. Basically say tomorrow you want to change the database location or user name or password or any other property of connectionstring you will have to recompile and then re-deploy your project.

There are some other problems as well with hardcoding. I am sure as you progress further you will see them in action. As of now just know that never hardcode your connection string in the code.

Also programming best practices are against hardcoding of anything.

And as mentioned, you should not assign me points if I did not answer your question.

Hope this helps.

Author

Commented:
Yeah.  I understand.  I am in an software engineering class and the web configuration can be configured through the properties.  I know. I understand where I went wrong..  You did not need to explain.  OK.  It was the deciding point in making me change mine about the direction of my program.  You have to understand that I know where you are coming from.  I  know something but I do not know others.  I am sorry if you felt that I insulted you but there were others who were very insulting.  But, I am still hear fighting with you (as experts trying to get my assignment completed!)  Sometimes, being an expert is giving suggestions that make the customers to change the direction of the program.  I am software engineering student.  If you object so strongly tell the administration to remove the points.  But, I really thank you.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
No no not really. I didnt feel insulted but yes I would like to clear any misunderstanding that you have regarding my answer. Also I strongly believe if we clear the fundamentals of programing at the begining life is really easy later on.

And I object regarding the points 'cause I do not feel its fair for me to receive the points if my answer was not satisfactory.

Also do not hesitate to ask questions which can help you clear the fundamentals. Also I was wondering if you would like to look at the existing samples? I know you have progressed a lot with your current project but would you like to see examples of Hit counter done by others?

Author

Commented:
I thought you had access to that question. I will send it to you.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
I have the code that you sent but I am not sure at what point you are facing a challenge? and that's what I really intende to ask in the first post :)

Author

Commented:
Here is the hit counter class.  I have a default class that is suppose to set up the website instance. I think I need a little help with the database.  I did this same program in a PHP class.  I did not realize it would be so difficult in C#.
HitCounter.cs
Default.aspx.cs
HitCounterDatabase.mdf
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Well now tell me what happens when you try to run your project?

Author

Commented:
I can show you better than I can tell you!  Just a moment!

Author

Commented:
I will edit the page to have only one output.

Author

Commented:
here the page lay out for the webpage.
Default.aspx
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Yes. So when you hit F5 what happens?

Author

Commented:
Nothing!
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Does it give any error or warning?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial