7 Replies - 1729 Views - Last Post: 25 February 2011 - 10:11 AM Rate Topic: -----

#1 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,370
  • Joined: 14-January 10

Building Database in VS2010

Posted 24 February 2011 - 05:35 PM

Hey everyone, I'm following the Head First C# book and it is talking about building a database. I built my database in Visual Studio 2010 by adding the database to my project. I now have the database built and it tells me to drag the database to the form. However, I would rather have my program only show what's in the database when you hit a button.

If that didn't make sense then let me explain. The program that the book teaches you to make is an Address Book program. However, I wanted to make a similiar program but I want it to do other things like you hit a button and then the address book pops up where you can add, edit, or delete the contacts. So basically all I need is to have a menu bar at the top that lets you access the database and make changes to it. Any suggestions on how I can do this?

Is This A Good Question/Topic? 0
  • +

Replies To: Building Database in VS2010

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,924
  • Joined: 02-June 10

Re: Building Database in VS2010

Posted 24 February 2011 - 05:47 PM

I'm sure the database is not a visible item. Just like dragging a timer to your form doesn't show GUI element for the timer. It just adds a reference to the object so you can use it.

Go ahead and follow the book and see what it does.
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Building Database in VS2010

Posted 24 February 2011 - 06:00 PM

I've read that book way back when. :3 It's not doing what you think it's doing Tlhq.

I don't remember exactly what it does behind scenes but you drag the table from the Server Explorer and automatically creates a CRUD form for you to use.

Can you check for me, and see if it create individual items (texbtox, label, etc.) or is it just one big control?
Was This Post Helpful? 0
  • +
  • -

#4 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,370
  • Joined: 14-January 10

Re: Building Database in VS2010

Posted 24 February 2011 - 06:05 PM

Yes, you drag it from the Explorer to the Form and it shows you a table. Above that it has a menu for you to add, edit, and delete stuff. But the way they teach it, the program opens up with that stuff. I want the program to open up with something else and for it to just have this feature built in.
Was This Post Helpful? 0
  • +
  • -

#5 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 308
  • Joined: 30-January 11

Re: Building Database in VS2010

Posted 24 February 2011 - 09:28 PM

If you are using the approach the book shows you can always right the objects to change them to diffrent controls, or add the controls you want then drag the items on top of controls.

Either way you could make the controls visible property false until you click the button.

Also the code generated for you in the load event could be moved to button event.

I do not really feel as though these are the best solutions, maybe let the button open a another form like the book created
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,924
  • Joined: 02-June 10

Re: Building Database in VS2010

Posted 25 February 2011 - 07:18 AM

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

Just in case you want to try a different source to work from.
Was This Post Helpful? 1
  • +
  • -

#7 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,370
  • Joined: 14-January 10

Re: Building Database in VS2010

Posted 25 February 2011 - 10:06 AM

I got to thinking about something that Jeff H said. In Outlook when you click on the Address Book button it opens another window or form. Can I do this in my program?

I know this may seem like a simple question, but most of my C# experience is with ASP.NET. So I don't know a lot building projects in forms.
Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4531
  • View blog
  • Posts: 7,902
  • Joined: 08-June 10

Re: Building Database in VS2010

Posted 25 February 2011 - 10:11 AM

Absolutely. Add another form to your project. You can create an instance of the form the same way you would with any other class, then use either .Show or .ShowDialog depending on which form of behavior you want (modeless or modal). You can follow this tutorial if you need to be able to pass data back and forth:

http://www.dreaminco...ny-other-forms/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1