M
Marc Llenas
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
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