none
Visual Studio 2012 Express/MySQL database questions

    Question

  • Hello everyone.

    I've made a similar post to this one a couple of weeks ago and it didn't really help me out, so I was hoping I could get a little more help this time. I had people suggest resouces last time, but I couldn't find what I needed.

    Basically, what I want to do now is have a database, with a single table for the time being. I want to be able to display and edit the database through a form with textboxes, labels, and buttons.

    What I have so far is that I opened a new project, created a form with the objects listed above, and created a table with similar columns to those objects.

    If I can remember correctly what my instructions were, they said to go to Project/Add New Item/Service-based Database. I then named it and followed the prompts. I clicked on it in the pane to the right. I then right-clicked Tables in the database explorer and selected Add New. I created a primary key called AID, which stands for Author ID. I created two other columns called AFirst (Author First Name) and ASur (Author Surname). I updated it to save it.

    Now that we know where I stand, what I need is for someone to help me connect it. One thing I don't get is whether that database is considered connected to the program or not. I know that it is in the program with my project and that it saves it in the same folder. However, is it treated like a random database somewhere else on the computer and you have to connect it the same way or can you just start coding in the project and have it access the database.

    Regardless of which of those it is, what is the code that will connect it. I'd like to be able to just test it by me adding entries to the DB and then when I run the program it lists them and lets me cycle through them. It would be a great starting point.

    Lastly for this post, is the database I used (service-based database) the correct one. Once I'm through with this program, I'd like to be able to publish my project and load it onto whatever computer I like and the database would stay with it.

    Thanks for all the help everyone and if you could walk me through this slowly, I'd really appreciate it. One last note is that this is a test for something I'd like to work on for my work. I'm at work and working on it with permission, but the company security blocks me from many things, including youtube, which is one suggestion of a person previously. It's good, but I couldn't really find anything that fit my level of understanding and I'd rather not work on work at home if you know what I mean. If anyone can help me out and explain this to me, I'd be very grateful. Please check back for my replies and once I get the basics down, I'll start a new thread with more specific questions. Thanks again.

    Wednesday, January 16, 2013 4:41 PM

Answers

  • You migtht want to edit your title since you don't appear to be using MySQL at all (you would be using SQL Express when using the Add New [Local/Service] Database option).

    If you are writing an application I would say that you can just create a new Local Database.  If you are writing a service then use the service-database.

    Once you've setup the database, you will need to open the DataSet that was created (assuming you chose dataset and not entity model) and regenerate the dataset based on the database layout.  Then you can either drag tables from the datasource window, or data components from the toolbox onto your form.

    I really suggest watching the Forms Over Data video series as this will walk you through all of the most common data access steps (assuming you take the time to watch each video to completion).


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Proposed as answer by Mike FengModerator Thursday, January 17, 2013 4:06 PM
    • Marked as answer by Daltonj Thursday, January 17, 2013 9:34 PM
    Wednesday, January 16, 2013 5:58 PM

All replies

  • You migtht want to edit your title since you don't appear to be using MySQL at all (you would be using SQL Express when using the Add New [Local/Service] Database option).

    If you are writing an application I would say that you can just create a new Local Database.  If you are writing a service then use the service-database.

    Once you've setup the database, you will need to open the DataSet that was created (assuming you chose dataset and not entity model) and regenerate the dataset based on the database layout.  Then you can either drag tables from the datasource window, or data components from the toolbox onto your form.

    I really suggest watching the Forms Over Data video series as this will walk you through all of the most common data access steps (assuming you take the time to watch each video to completion).


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Proposed as answer by Mike FengModerator Thursday, January 17, 2013 4:06 PM
    • Marked as answer by Daltonj Thursday, January 17, 2013 9:34 PM
    Wednesday, January 16, 2013 5:58 PM
  • I will certainly watch the videos. I was under the assumption that I was using MySQL. I downloaded it. Should I be using it instead? Is it better or easier than SQL Express?

    When I downloaded MySQL and try to open it, it just opens a Visual Studio 2010 shell.

    Wednesday, January 16, 2013 6:15 PM
  • Hi Daltonj,

    Welcome to the MSDN Forum.

    >>When I downloaded MySQL and try to open it, it just opens a Visual Studio 2010 shell.

    Please try MYSql office forum, it is the third party product here.

    Thank you for your understanding and support.

    If you need to use SQL Express, please try Reed's suggestion.

    Thanks.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 4:09 PM
  • MySQL is an alternative to MS SQL.  But SQL Express is bundled with VS now so you get it when you install VS.

    Typically you only see people using MySQL when the database is too large/complex/too many users for SQL Express, but the person does not want to pay for a full version of SQL Server.  I personally never use it as SQL express meets most stand-alone application needs and I already have a full SQL Server for enterprise application needs.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Thursday, January 17, 2013 5:36 PM
  • Thanks everyone. I didn't know that Reed. I assumed you needed both. I didn't know it was a package now. I believe the last time I tried to code, I was on VS 2005 Express and it either wasn't packaged with it or I just didn't know it. I think at the time I was told I needed to get MySQL.
    Thursday, January 17, 2013 9:34 PM