473,606 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 OleDbDataAdapte r
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=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "App_data\backe nd.mdb") & ";Persist Security Info=False"
9
10 'Build the SQL string
11 strSQL = "SELECT TblProperty.Pro ID, TblProperty.Pro Name,
[TblCategory]![CatNumber] & ' Estrellas (' & [TblCategory]![CatStars] & ')'
AS FullCat, [TblProperty]![ProCity] & ' (' & [TblProperty]![ProProvince] &
')' AS FullLocation, TblProperty.Pro Description, TblProperty.Pro ImagePath,
TblProperty.Pro Logo1Path, TblProperty.Pro Logo2Path,
TblProperty.Pro Logo3Path, TblProperty.Pro Logo4Path FROM TblCategory INNER
JOIN TblProperty ON TblCategory.Cat ID = TblProperty.Pro CatID;"
12
13 'Create the connection and command objects
14 objConn = New OleDbConnection (strConn)
15 objAdapt = New OleDbDataAdapte r(strSQL, objConn)
16
17 'Fill the dataset with the results of the query
18 objAdapt.Fill(o bjDataSet, "TblPropert y")
19
20 'Set the repeater's source to the dataset and bind the data
21 objRepeater.Dat aSource = objDataSet.Tabl es("TblProperty ").DefaultV iew
22 objRepeater.Dat aBind()

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 1545
Hi
You can use DataTable's TableName property :

objAdapt.Fill(o bjDataSet, objDataSet.Tabl es[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*****@randag roup.es> wrote in message
news:%2******** ********@TK2MSF TNGP11.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 OleDbDataAdapte r
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=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "App_data\backe nd.mdb") & ";Persist Security Info=False"
9
10 'Build the SQL string
11 strSQL = "SELECT TblProperty.Pro ID, TblProperty.Pro Name,
[TblCategory]![CatNumber] & ' Estrellas (' & [TblCategory]![CatStars] &
')' AS FullCat, [TblProperty]![ProCity] & ' (' &
[TblProperty]![ProProvince] & ')' AS FullLocation,
TblProperty.Pro Description, TblProperty.Pro ImagePath,
TblProperty.Pro Logo1Path, TblProperty.Pro Logo2Path,
TblProperty.Pro Logo3Path, TblProperty.Pro Logo4Path FROM TblCategory INNER
JOIN TblProperty ON TblCategory.Cat ID = TblProperty.Pro CatID;"
12
13 'Create the connection and command objects
14 objConn = New OleDbConnection (strConn)
15 objAdapt = New OleDbDataAdapte r(strSQL, objConn)
16
17 'Fill the dataset with the results of the query
18 objAdapt.Fill(o bjDataSet, "TblPropert y")
19
20 'Set the repeater's source to the dataset and bind the data
21 objRepeater.Dat aSource = objDataSet.Tabl es("TblProperty ").DefaultV iew
22 objRepeater.Dat aBind()

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*********@go oglemail.com> escribió en el mensaje
news:ee******** ******@TK2MSFTN GP10.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*****@randag roup.es> wrote in message
news:%2******** ********@TK2MSF TNGP11.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 OleDbDataAdapte r
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=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "App_data\backe nd.mdb") & ";Persist Security Info=False"
9
10 'Build the SQL string
11 strSQL = "SELECT TblProperty.Pro ID, TblProperty.Pro Name,
[TblCategory]![CatNumber] & ' Estrellas (' & [TblCategory]![CatStars] &
')' AS FullCat, [TblProperty]![ProCity] & ' (' &
[TblProperty]![ProProvince] & ')' AS FullLocation,
TblProperty.Pro Description, TblProperty.Pro ImagePath,
TblProperty.Pro Logo1Path, TblProperty.Pro Logo2Path,
TblProperty.Pro Logo3Path, TblProperty.Pro Logo4Path FROM TblCategory INNER
JOIN TblProperty ON TblCategory.Cat ID = TblProperty.Pro CatID;"
12
13 'Create the connection and command objects
14 objConn = New OleDbConnection (strConn)
15 objAdapt = New OleDbDataAdapte r(strSQL, objConn)
16
17 'Fill the dataset with the results of the query
18 objAdapt.Fill(o bjDataSet, "TblPropert y")
19
20 'Set the repeater's source to the dataset and bind the data
21 objRepeater.Dat aSource = objDataSet.Tabl es("TblProperty ").DefaultV iew
22 objRepeater.Dat aBind()

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
307
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 the Fill method several times, only with a limited number of records, as I have very many records in the database. The dataset is attached to a control (listbox) and I would like that the listbox appears quickly on screen with some 50 records...
2
1273
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 Query Analyzer, but when I run it from my web page I kept getting a TimeOut exception. So then, as an experiment, I changed the way I created the adapter to the following: SqlConnection conn = new SqlConnection(m_Conn); SqlCommand sqlCommand =...
4
1597
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 are both foreign keys to the address table. So, the stored procedure to which my SelectCommand points to reads as: ALTER PROCEDURE dbo.CompanyInfoByCompanyID ( @companyid int
3
1022
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(); dataAdap.Fill(dataSet, "Region");
1
4845
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
2290
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 6 to 15 times a day the server hangs and times out when this fill method is called. The SP is simple and uses very little resources (as tested using client statistics in query analyzer). Here's data from my error log which includes the...
2
2099
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 simple code below: ---------------------------------------------------------------- Private cob As SqlCommandBuilder Private con As SqlConnection Private cur As CurrencyManager
6
2464
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 --------------------------------------------------------------------------------- @strProductCode nvarchar (50)
0
4544
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 IBM.Data.DB2.iSeries; Version: v1.0.3705 (is there an newer one for OS/400 Version ist V5R3 ?) or is it a hardware faoult (memory of as400 or pc) ? br mike Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein...
0
8036
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8126
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6796
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2454
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.