Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Fill method for Dataset

Reply
Thread Tools

Fill method for Dataset

 
 
Marc Llenas
Guest
Posts: n/a
 
      02-20-2006
Hello all,

I'm new to ASP.NET and I have a question regarding the fill method of a
dataset.

Here is my code

1 Dim objConn As OleDbConnection
2 Dim objAdapt As OleDbDataAdapter
3 Dim strConn As String
4 Dim strSQL As String
5 Dim objDataSet As New DataSet
6
7 'Build the connection string
8 strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("App_data\backend.mdb") & ";Persist Security Info=False"
9
10 'Build the SQL string
11 strSQL = "SELECT TblProperty.ProID, TblProperty.ProName,
[TblCategory]![CatNumber] & ' Estrellas (' & [TblCategory]![CatStars] & ')'
AS FullCat, [TblProperty]![ProCity] & ' (' & [TblProperty]![ProProvince] &
')' AS FullLocation, TblProperty.ProDescription, TblProperty.ProImagePath,
TblProperty.ProLogo1Path, TblProperty.ProLogo2Path,
TblProperty.ProLogo3Path, TblProperty.ProLogo4Path FROM TblCategory INNER
JOIN TblProperty ON TblCategory.CatID = TblProperty.ProCatID;"
12
13 'Create the connection and command objects
14 objConn = New OleDbConnection(strConn)
15 objAdapt = New OleDbDataAdapter(strSQL, objConn)
16
17 'Fill the dataset with the results of the query
18 objAdapt.Fill(objDataSet, "TblProperty")
19
20 'Set the repeater's source to the dataset and bind the data
21 objRepeater.DataSource = objDataSet.Tables("TblProperty").DefaultView
22 objRepeater.DataBind()

My question is related to line's 18 and 21. In all examples I have reviewed
the SQL string relates to a single table and the name of that table is
refered in those lines.

In my case my SQL sentence has a join so I'm not sure how to go about it.

Any suggestions?

Thanks,

Marc



 
Reply With Quote
 
 
 
 
Aboulfazl Hadi
Guest
Posts: n/a
 
      02-20-2006
Hi
You can use DataTable's TableName property :

objAdapt.Fill(objDataSet, objDataSet.Tables[0].TablenName)

Best Regards,
A.Hadi

 
Reply With Quote
 
 
 
 
vinu
Guest
Posts: n/a
 
      02-20-2006
Hello Mark,

There is nothing wrong with you code. I thing you are getting confused. The
simplest way to understand this is..
When you execute the sql statement you get the resultset which satisfies the
all your join condition, that resultset then get loaded in to dataset.
Think like dataset as basket, where you can store lot of item. The table
name you give in the Fill statement has nothing to do with actual table, you
can specify any name.

Hope its clear now....

vinu





"Marc Llenas" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hello all,
>
> I'm new to ASP.NET and I have a question regarding the fill method of a
> dataset.
>
> Here is my code
>
> 1 Dim objConn As OleDbConnection
> 2 Dim objAdapt As OleDbDataAdapter
> 3 Dim strConn As String
> 4 Dim strSQL As String
> 5 Dim objDataSet As New DataSet
> 6
> 7 'Build the connection string
> 8 strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> Server.MapPath("App_data\backend.mdb") & ";Persist Security Info=False"
> 9
> 10 'Build the SQL string
> 11 strSQL = "SELECT TblProperty.ProID, TblProperty.ProName,
> [TblCategory]![CatNumber] & ' Estrellas (' & [TblCategory]![CatStars] &
> ')' AS FullCat, [TblProperty]![ProCity] & ' (' &
> [TblProperty]![ProProvince] & ')' AS FullLocation,
> TblProperty.ProDescription, TblProperty.ProImagePath,
> TblProperty.ProLogo1Path, TblProperty.ProLogo2Path,
> TblProperty.ProLogo3Path, TblProperty.ProLogo4Path FROM TblCategory INNER
> JOIN TblProperty ON TblCategory.CatID = TblProperty.ProCatID;"
> 12
> 13 'Create the connection and command objects
> 14 objConn = New OleDbConnection(strConn)
> 15 objAdapt = New OleDbDataAdapter(strSQL, objConn)
> 16
> 17 'Fill the dataset with the results of the query
> 18 objAdapt.Fill(objDataSet, "TblProperty")
> 19
> 20 'Set the repeater's source to the dataset and bind the data
> 21 objRepeater.DataSource = objDataSet.Tables("TblProperty").DefaultView
> 22 objRepeater.DataBind()
>
> My question is related to line's 18 and 21. In all examples I have
> reviewed the SQL string relates to a single table and the name of that
> table is refered in those lines.
>
> In my case my SQL sentence has a join so I'm not sure how to go about it.
>
> Any suggestions?
>
> Thanks,
>
> Marc
>
>
>



 
Reply With Quote
 
Marc Llenas
Guest
Posts: n/a
 
      02-20-2006
Gotcha, so the name I give in the Fill statement is like an "alias" to
reference it later on the repeater's DataSource.

Thanks a lot Vinu, I think it's clear now.

Cheers,

Marc


"vinu" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> Hello Mark,
>
> There is nothing wrong with you code. I thing you are getting confused.
> The simplest way to understand this is..
> When you execute the sql statement you get the resultset which satisfies
> the all your join condition, that resultset then get loaded in to dataset.
> Think like dataset as basket, where you can store lot of item. The table
> name you give in the Fill statement has nothing to do with actual table,
> you can specify any name.
>
> Hope its clear now....
>
> vinu
>
>
>
>
>
> "Marc Llenas" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hello all,
>>
>> I'm new to ASP.NET and I have a question regarding the fill method of a
>> dataset.
>>
>> Here is my code
>>
>> 1 Dim objConn As OleDbConnection
>> 2 Dim objAdapt As OleDbDataAdapter
>> 3 Dim strConn As String
>> 4 Dim strSQL As String
>> 5 Dim objDataSet As New DataSet
>> 6
>> 7 'Build the connection string
>> 8 strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>> Server.MapPath("App_data\backend.mdb") & ";Persist Security Info=False"
>> 9
>> 10 'Build the SQL string
>> 11 strSQL = "SELECT TblProperty.ProID, TblProperty.ProName,
>> [TblCategory]![CatNumber] & ' Estrellas (' & [TblCategory]![CatStars] &
>> ')' AS FullCat, [TblProperty]![ProCity] & ' (' &
>> [TblProperty]![ProProvince] & ')' AS FullLocation,
>> TblProperty.ProDescription, TblProperty.ProImagePath,
>> TblProperty.ProLogo1Path, TblProperty.ProLogo2Path,
>> TblProperty.ProLogo3Path, TblProperty.ProLogo4Path FROM TblCategory INNER
>> JOIN TblProperty ON TblCategory.CatID = TblProperty.ProCatID;"
>> 12
>> 13 'Create the connection and command objects
>> 14 objConn = New OleDbConnection(strConn)
>> 15 objAdapt = New OleDbDataAdapter(strSQL, objConn)
>> 16
>> 17 'Fill the dataset with the results of the query
>> 18 objAdapt.Fill(objDataSet, "TblProperty")
>> 19
>> 20 'Set the repeater's source to the dataset and bind the data
>> 21 objRepeater.DataSource = objDataSet.Tables("TblProperty").DefaultView
>> 22 objRepeater.DataBind()
>>
>> My question is related to line's 18 and 21. In all examples I have
>> reviewed the SQL string relates to a single table and the name of that
>> table is refered in those lines.
>>
>> In my case my SQL sentence has a join so I'm not sure how to go about it.
>>
>> Any suggestions?
>>
>> Thanks,
>>
>> Marc
>>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: how-to fill a DataSet from an OleDbDataReader Alex Papadimoulis ASP .Net 3 09-18-2003 07:53 PM
Re: how-to fill a DataSet from an OleDbDataReader William Ryan ASP .Net 0 09-17-2003 04:01 PM
Re: how-to fill a DataSet from an OleDbDataReader Christian Pické ASP .Net 0 09-17-2003 02:05 PM
Re: how-to fill a DataSet from an OleDbDataReader Jay Balapa ASP .Net 0 09-17-2003 02:02 PM
Re: how-to fill a DataSet from an OleDbDataReader Mark Kamoski ASP .Net 0 09-17-2003 02:01 PM



Advertisments