473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Fill method for Dataset

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

Feb 20 '06 #1
3 1533
Hi
You can use DataTable's TableName property :

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

Best Regards,
A.Hadi

Feb 20 '06 #2
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" <ml*****@randagroup.es> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Feb 20 '06 #3
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" <vi*********@googlemail.com> escribió en el mensaje
news:ee**************@TK2MSFTNGP10.phx.gbl...
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" <ml*****@randagroup.es> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Feb 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Abra | last post by:
Is it possible to fill a ADO.NET dataset incrementally ? (I mean to call the DataAdapter Fill() method several times, as I did not found a Add() method) I would like to call in a background thread...
2
by: Dan | last post by:
I've created a web form which fills a DataGrid with a DataSet generated from the SqlDataAdapter.Fill method. The adapter's query takes about 30 seconds to complete when I run it in the SQL Server...
4
by: Mervin Williams | last post by:
I have several tables involved in my application, but the two in question here are the company and address tables. The company table has business_address_id and mailing_address_id columns, which...
3
by: Pawel Blochowiak | last post by:
Hello Everybody SqlConnection conn = new SqlConnection(str); DataSet dataSet = new DataSet(); SqlDataAdapter dataAdap = new SqlDataAdapter("select * from Region", conn); conn.Open();...
1
by: Nikolay Petrov | last post by:
How to fill dataset with multiple tables and set their relaition? Can I get the relations from the SQL server? Also I would like to do it using stored procedures. TIA
5
by: moondaddy | last post by:
I have a website where cataloge pages are populated by calling a stored procedure on sql server. I use the sql data adapter's fill method to call this stored procedure and fill the dataset. about...
2
by: pwh777 | last post by:
I need help in understanding the DataAdapter Fill method and how it relates to the binding to controls on a form. I have a table called tbl_CID_XRef on SQL Server. I have written as a test the...
6
by: Laura K | last post by:
This is probably a simple question but I want to make sure I am doing it right. I have a spoc with two select statements which results in two tables. Very Basic ...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.