Svekke
Member
- Joined
- Jul 27, 2010
- Messages
- 14
- Programming Experience
- Beginner
Hello all,
I'm trying to make a program in which football (or some other sport) prognostics can be entered and scores can be calculated automatically.
I've set up the database and I've created 3 layers. In the data layer, I've added my access 2007 database (it already has the right links between the tables). These are my 'PrognoMakerDataSet.xsd'
I've also created an sql statement in the table 'teams' to collect the teamitems (name, ID, foundationyear) and to collect the coach's name and the countryname from the 'COACHES' and 'COUNTRIES' tables.
When I run this sql in preview, the correct output show up. So far so good. The SQL code is the following:
I've also created a presentation layer, with 2 things on it. A button (btnGetAllTeams) (if clicked, a gridview shows up) and a gridview grdvAllTeams.
In my presentation layer, I have the following code
This code uses the Business layer to reach the data layer. So far so good ? Or not?
In my business layer, I have the following code:
The problem is, when I click the btnGetAllTeams, the gridview pops up, but it contains 'TEAMID', 4 blank columns (teamname, teamcountry, ...), and then the correct columns that i need in my output.
I did notice that if i click 'execute query' in the dataset (when configuring the sql), I get the perfect output. When I click 'preview' in the dataset (after clicking on a table itself), I get the wrong output.
I'm only a beginner, so I'm probably making a lot of big mistakes that don't make any sense, but could someone please have a look at my code and try to tell me what's wrong about it?
PS: I've added a screenshot of the output in attachment:
I'm trying to make a program in which football (or some other sport) prognostics can be entered and scores can be calculated automatically.
I've set up the database and I've created 3 layers. In the data layer, I've added my access 2007 database (it already has the right links between the tables). These are my 'PrognoMakerDataSet.xsd'
I've also created an sql statement in the table 'teams' to collect the teamitems (name, ID, foundationyear) and to collect the coach's name and the countryname from the 'COACHES' and 'COUNTRIES' tables.
When I run this sql in preview, the correct output show up. So far so good. The SQL code is the following:
VB.NET:
Select TEAMS.TeamID as TeamID, strconv((TEAMS.TeamName),3) as Name,
strconv((COUNTRIES.CountryName),3)as Country, strconv(COACHES.CoachName,3) as Coach,
TEAMS.FoundationYear as Foundation
FROM ((TEAMS LEFT JOIN COACHES ON TEAMS.TeamCoach = COACHES.CoachID)
LEFT JOIN COUNTRIES ON TEAMS.TeamCountry = COUNTRIES.CountryID)
ORDER by TEAMS.TEAMNAME
I've also created a presentation layer, with 2 things on it. A button (btnGetAllTeams) (if clicked, a gridview shows up) and a gridview grdvAllTeams.
In my presentation layer, I have the following code
VB.NET:
Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class Teams
Dim BLLteams As New BLL_TEAMS
Private Sub Teams_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim teams As New DataTable
Me.grdvAllTeams.Visible = False
teams = BLLteams.getAllTeams
Me.grdvAllTeams.DataSource = teams
End Sub
Private Sub btnGetAllTeams_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetAllTeams.Click
Me.grdvAllTeams.Visible = True
grdvAllTeams.Refresh()
End Sub
End Class
This code uses the Business layer to reach the data layer. So far so good ? Or not?
In my business layer, I have the following code:
VB.NET:
Imports Microsoft.VisualBasic
Imports Prognomaker.PrognomakerDataSetTableAdapters
Imports System.Data
Public Class BLL_TEAMS
Dim m_TeamNaam As String
Dim teamadapter As New PrognomakerDataSetTableAdapters.TEAMSTableAdapter
Dim m_rowsaffected As Integer
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, False)> _
Public Function getAllTeams() As PrognomakerDataSet.TEAMSDataTable
' deze functie geeft ALLE teams terug aan de presentation layer
Try
Dim teams As New DataTable
teams = teamadapter.GetAllTeams
' vul de datatable met alle klanten, en stuur deze terug naar de PLL
Return teams
Catch exc As Exception
MsgBox("Er zijn nog geen teams aangemaakt.")
End Try
Return Nothing
End Function
End Class
The problem is, when I click the btnGetAllTeams, the gridview pops up, but it contains 'TEAMID', 4 blank columns (teamname, teamcountry, ...), and then the correct columns that i need in my output.
I did notice that if i click 'execute query' in the dataset (when configuring the sql), I get the perfect output. When I click 'preview' in the dataset (after clicking on a table itself), I get the wrong output.
I'm only a beginner, so I'm probably making a lot of big mistakes that don't make any sense, but could someone please have a look at my code and try to tell me what's wrong about it?
PS: I've added a screenshot of the output in attachment: