Showing posts with label description. Show all posts
Showing posts with label description. Show all posts

Thursday, March 22, 2012

Dataset to Generic List. How to do this?

Hello,

I have a DataSet which results from accessing an SQL database.
Each row is an Article and has various columns like Title, Description, etc.

I have created a Generic List as follows:
Dim Articles As Generic.List(Of Article)

Article is a class with various properties. Each property is the same as each column in the dataset.

I want to fill the Generic List with the data from my DataSet.

How can I do this?

Thanks,
Miguel

Hi Miguel,

Here's an example:

PublicFunction GetArticles()As List(Of Article)
Dim articlesAsNew List(Of Article)
Dim connStrAsString

connStr = ConfigurationManager.ConnectionStrings.Item("MyDB").ConnectionString
Dim connAsNew SqlConnection(connStr)

Using cmdAsNew SqlCommand("select ArticleID, Title, Published from Articles", conn)

Dim dsAsNew DataSet()
Dim daAsNew SqlDataAdapter(cmd)

da.Fill(ds,"Articles")

Dim rowAs DataRow

ForEach rowIn ds.Tables("Articles").Rows
Dim artAsNew Article

art.ArticleID = row("ArticleID")
art.Title = row("Title")
art.Published = row("Published")

articles.Add(art)
Next
EndUsing

Return articles

EndFunctionJoe

Sunday, February 19, 2012

database with two data files

I only need short description or even link about database with two data
files and/or two log files. How does it work,...?
thanks
Hi
In BOL, look up the keyword "filegroups, described". Gives a perfect
description and examples.
Regards
Mike
"Lugos" wrote:

> I only need short description or even link about database with two data
> files and/or two log files. How does it work,...?
> thanks
>
|||Thanks. That's what I am looking for. Shame is i did not find it myself.
Mike Epprecht (SQL MVP) wrote:[vbcol=seagreen]
> Hi
> In BOL, look up the keyword "filegroups, described". Gives a perfect
> description and examples.
> Regards
> Mike
> "Lugos" wrote:
>

database with two data files

I only need short description or even link about database with two data
files and/or two log files. How does it work,...?
thanksHi
In BOL, look up the keyword "filegroups, described". Gives a perfect
description and examples.
Regards
Mike
"Lugos" wrote:
> I only need short description or even link about database with two data
> files and/or two log files. How does it work,...?
> thanks
>|||Thanks. That's what I am looking for. Shame is i did not find it myself.
Mike Epprecht (SQL MVP) wrote:
> Hi
> In BOL, look up the keyword "filegroups, described". Gives a perfect
> description and examples.
> Regards
> Mike
> "Lugos" wrote:
>
>>I only need short description or even link about database with two data
>>files and/or two log files. How does it work,...?
>>thanks

database with two data files

I only need short description or even link about database with two data
files and/or two log files. How does it work,...?
thanksHi
In BOL, look up the keyword "filegroups, described". Gives a perfect
description and examples.
Regards
Mike
"Lugos" wrote:

> I only need short description or even link about database with two data
> files and/or two log files. How does it work,...?
> thanks
>|||Thanks. That's what I am looking for. Shame is i did not find it myself.
Mike Epprecht (SQL MVP) wrote:[vbcol=seagreen]
> Hi
> In BOL, look up the keyword "filegroups, described". Gives a perfect
> description and examples.
> Regards
> Mike
> "Lugos" wrote:
>