Results 1 to 6 of 6

Thread: [2005] Database question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Question [2005] Database question

    Hey guys,

    I have added a database to my project which i have called StudentDatabase.

    So i now have StudentDatabase.mdf and StudentDatabaseDataSet.xsd in my Solution Explorer, but as i have never used databases this way before I dont know where to go from here to create sql commands to create tables and then insert, update, select and delete from. So i was wondering whether anybody would be able to write me a bit of code to help me get on my way, or post a link to a website where i could find out how to use my database.

    Thanks in advance for any help
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [2005] Database question

    First, I would do a search on thsi forum. I am sure there are plenty of examples. Second, I would look at some of the signatures of the responders. Many of those have links to coding examples.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3
    Fanatic Member onlyGirl's Avatar
    Join Date
    Sep 2006
    Location
    Houston, TX
    Posts
    743

    Re: [2005] Database question

    There's many a couple of ways to do it but here's one:

    Code:
    Dim cmdSelect as New OleDbCommand
    Dim daSelect as New OleDbDataAdapter
    Dim dsSelect as New Dataset
    
    cmdSelect = "YOUR SQL STATEMENT"
    daInset.SelectCommand = cmdSelect
    cmdSelect.Connection = "YOUR CONNECTION HERE"
    daSelect.Fill (YOUR DATASET)
    Using Visual Studio 2008

    Please mark your thread RESOLVED if you no longer need help.

  4. #4
    Fanatic Member onlyGirl's Avatar
    Join Date
    Sep 2006
    Location
    Houston, TX
    Posts
    743

    Re: [2005] Database question

    Using Visual Studio 2008

    Please mark your thread RESOLVED if you no longer need help.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: [2005] Database question

    Hey, thanx for the replies. I have one more question though...what do i put for my connection string, because surely if i've added to database to my project, isn't it already connected??? Or am i just talkin complete rubbish (which would be the shock of the century! :-P lol)

    Thanks again.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Database question

    When you added the database to your project the system created a typed DataSet for you. The XSD file is the XML schema description of that DataSet. Along with the DataSet it also created TableAdapters. All the connection and SQL information is encapsulated within them. As you add tables and columns to your database you should regenerate your DataSet using the Configure button in the Data Sources window. That will re-run the wizard allow you to change the schema of your DataSet to match the database.

    Once that's done you simply create an instance of your DataSet and the appropriate TableAdapter, then call the Fill method of the TableAdapter to populate the corresponding DataTable in the DataSet.

    You can create the objects by dragging them from the Toolbox window onto your form or else you can create them in code, just like any other objects. You can also create them and corresponding bound controls by dragging tables and columns from the Data Sources window onto your form.

    I suggest that you start reading here.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width