2007-10-25

Populate a DataSet from a Database

SqlDataAdapter class represents a set of data commands and a database connection that are used to fill the DataSet and update a SQL Server database. This class cannot be inherited.

Getting data from a database is easy, and working with data is easier than before. The most important concept to remember is that the DataSet is a data structure separate and distinct from a data store. Although you get data from a database in this example, it doesn't matter where the data comes from; the DataSet will always present a consistent programming model. It is a simple collection of data with relational database characteristics. There is no Load, Open, or Execute on a DataSet because it doesn't know where it gets its data from. This section describes how to use a SqlDataAdapter to get data from a database into a DataSet.

Sample Code (with MsSql)

Dim sConnection As String = "server=(local);uid=sa;pwd=password;database=yourDatabase"

Dim objDataAdapter As New SqlDataAdapter("Select * From tableName", sConnection)
Dim dsResult As New DataSet("Result")

If Not IsNothing(objDataAdapter) Then
' Fill data into dataset
objDataAdapter.Fill(dsResult)

objDataAdapter.Dispose()
End If

' Test by bind data into datagridview control
Me.DataGridView1.DataSource = dsResult.Tables(0)

40 comments:

Anonymous said...

Amiable post and this enter helped me alot in my college assignement. Say thank you you on your information.

Anonymous said...

Hi,

I begin on internet with a directory

Anonymous said...

be happy and love. kiss

Anonymous said...

Wow, wonderful weblog format! How lengthy have you ever been blogging for?
you make running a blog look easy. The entire look of your
web site is great, let alone the content!

My webpage Abercrombie & Fitch

Anonymous said...

I love what you guys are up too. This kind of clever work and exposure!
Keep up the excellent works guys I've you guys to my own blogroll.

Also visit my web blog; Cheap Jerseys

Anonymous said...

What's up, I read your blog on a regular basis. Your writing style is awesome, keep up the good work!

Here is my website; Gucci Sito Ufficiale

Anonymous said...

There's certainly a lot to find out about this issue. I love all of the points you have made.

Also visit my web blog ... Evgeni Malkin Jersey Authentic Evgeni Malkin Jersey Evgeni Malkin Authentic Jersey Evgeni Malkin Black Jersey Evgeni Malkin Black Jersey

Anonymous said...

An impressive share! I've just forwarded this onto a friend who was conducting a little homework on this. And he actually bought me dinner simply because I discovered it for him... lol. So allow me to reword this.... Thanks for the meal!! But yeah, thanks for spending some time to discuss this matter here on your web site.

Feel free to visit my weblog ... Louis Vuitton Handbags

Anonymous said...

Keep this going please, great job!

My site - Converse Basse

Anonymous said...

What's up to all, how is all, I think every one is getting more from this site, and your views are pleasant in favor of new viewers.

Look at my page - Louis Vuitton Handbags

Anonymous said...

Hi there, You have done an incredible job. I will certainly digg it and personally recommend to my friends.
I am sure they will be benefited from this site.

Also visit my website ... Get the Facts

Anonymous said...

You actually make it seem so easy with your presentation but I find this matter to be actually something
which I think I would never understand. It seems too complicated and very broad
for me. I am looking forward for your next post, I will try to get the hang of it!


My webpage :: article source

Anonymous said...

I'd like to find out more? I'd care to find out more details.


Also visit my blog - Abercrombie

Anonymous said...

Oh my goodness! Incredible article dude! Many thanks, However I
am going through difficulties with your RSS. I don't know the reason why I cannot join it. Is there anyone else having the same RSS issues? Anybody who knows the answer will you kindly respond? Thanks!!

Here is my blog; Chaussures De Football

Anonymous said...

This is really interesting, You are a very skilled blogger.
I have joined your feed and look forward to seeking more of your magnificent post.
Also, I've shared your web site in my social networks!

My web blog - Nike Air Jordan

Anonymous said...

I used to be able to find good info from your blog posts.


Feel free to visit my web-site; Louis Vuitton Handbags Outlet

Anonymous said...

Great information. Lucky me I came across your site by accident (stumbleupon).

I've book marked it for later!

Here is my web site :: Cheap Louis Vuitton Bags

Anonymous said...

We're a group of volunteers and starting a new scheme in our community. Your site offered us with valuable info to work on. You have done an impressive job and our entire community will be grateful to you.

Also visit my site Wholesale Jerseys

Anonymous said...

It's really a cool and helpful piece of information. I'm happy that you shared this helpful info with
us. Please keep us up to date like this. Thank you for sharing.


Visit my web page :: ngosummit.com

Anonymous said...

WOW just what I was searching for. Came here by searching for counterpoint

my web-site Sac a main Guess

Anonymous said...

Hi, always i used to check blog posts here in the early hours in the morning, as i love to gain
knowledge of more and more.

Feel free to surf to my homepage link

Anonymous said...

If some one desires expert view about running a blog
then i propose him/her to go to see this webpage, Keep
up the pleasant work.

Here is my web page: website

Anonymous said...

Keep this going please, great job!

Also visit my web site; Going Here

Anonymous said...

This teхt is prісelеsѕ.
When can I fіnԁ out mοre?

Heге is my homepаge :: legal ecstasy alternative

Anonymous said...

Magnificent goods from you, man. I've understand your stuff previous to and you're just extremely
great. I really like what you've acquired here, certainly like what you are stating and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can not wait to read far more from you. This is really a wonderful web site.

my webpage :: next page

Anonymous said...

Hi, i think that i noticed you visited my site so i came to go
back the prefer?.I am attempting to to find things to enhance my website!
I assume its ok to use some of your ideas!!

Look at my weblog; Clicking Here

Anonymous said...

My partner and I stumbled over here by a different web page and thought I may as well check things out.
I like what I see so now i'm following you. Look forward to checking out your web page for a second time.

My web site; related site

Anonymous said...

If some one needs to be updated with hottest technologies therefore he must be pay a visit this web site and be up
to date everyday.

Stop by my page; Christian Louboutin Outlet

Anonymous said...

Great delivery. Great arguments. Keep up the good spirit.


my weblog; Christian Louboutin Sale

Anonymous said...

Oh my goodness! Amazing article dude! Thanks, However I am having problems with your RSS.
I don't understand the reason why I can't subscribe to it.
Is there anyone else having the same RSS problems?
Anyone who knows the answer will you kindly respond?
Thanks!!

Feel free to visit my site: Tory Burch Outlet (ngosummit.com)

Anonymous said...

Hi Dear, are you truly visiting this web site regularly, if so after that you will definitely take fastidious experience.


my homepage Oakley Sunglasses

Anonymous said...

Hello to every body, it's my first pay a visit of this web site; this weblog includes awesome and in fact excellent information in support of visitors.

My web page ... Sac A Main Louis Vuitton

Anonymous said...

Thank you a bunch for sharing this with all folks you actually understand what you are speaking about!

Bookmarked. Please also visit my site =). We could have a hyperlink
exchange agreement among us

Also visit my page web site

Anonymous said...

When someone writes an paragraph he/she retains the plan of a user in his/her
brain that how a user can understand it. Therefore that's why this piece of writing is perfect. Thanks!

Look at my blog post Chaussures De Foot Pas Cher

Anonymous said...

I really like what you guys are up too. This sort of clever work and coverage!
Keep up the awesome works guys I've added you guys to our blogroll.

my webpage; Nike Black Blazers

Anonymous said...

I'll right away take hold of your rss as I can not in finding your e-mail subscription link or e-newsletter service. Do you've any?
Please allow me realize in order that I could subscribe.
Thanks.

Feel free to surf to my homepage ... Clicking Here

Anonymous said...

Hi there this is kind of of off topic but I was wanting to know if blogs
use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding expertise so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!

Feel free to surf to my webpage :: Boutique Air Jordan

Anonymous said...

I've read a few good stuff here. Certainly price bookmarking for revisiting. I surprise how so much attempt you set to create this kind of magnificent informative web site.

Feel free to visit my site; Sac Guess

Anonymous said...

you are actually a good webmaster. The web site loading speed is incredible.
It seems that you are doing any distinctive trick. Furthermore, The contents are masterwork.
you have done a fantastic task on this matter!



my blog: Michael Kors

Anonymous said...

Write morе, thatѕ all I have to say. Literallу, it seems аs though you relied
οn the viԁeo to mаkе your point. Үou obviοusly
know what youre talking about, why throw away your іntelligence on just posting vіdeos to your weblog when you could bе giving uѕ something enlightening to rеad?


Visit my web page: caffeine pills energy drinks