|
-
Apr 23rd, 2008, 11:23 AM
#1
Thread Starter
Fanatic Member
[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 
-
Apr 23rd, 2008, 02:01 PM
#2
PowerPoster
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]
-
Apr 23rd, 2008, 02:10 PM
#3
Fanatic Member
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.
-
Apr 23rd, 2008, 02:11 PM
#4
Fanatic Member
Re: [2005] Database question
Using Visual Studio 2008
Please mark your thread RESOLVED if you no longer need help.
-
Apr 23rd, 2008, 05:19 PM
#5
Thread Starter
Fanatic Member
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 
-
Apr 23rd, 2008, 11:26 PM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|