Im currently using a string to store my query in VB.
It seems to work perfectly fine for short queries.
But as my queries become longer and longer, this method just doesnt seem to work.
Im using an access database and when i run my SQL queries in that they work fine its just when i transfer them to the vb code they seem to cause errors.
So is there a way to call saved access queries in vb without actually putting the query string in the code?
This is the code im currently using it would be nice if a solution followed this general pattern of interacting with a database:
Note: the strSportSQL string is actually all on one line, this forum displays it differently.
It seems to work perfectly fine for short queries.
But as my queries become longer and longer, this method just doesnt seem to work.
Im using an access database and when i run my SQL queries in that they work fine its just when i transfer them to the vb code they seem to cause errors.
So is there a way to call saved access queries in vb without actually putting the query string in the code?
This is the code im currently using it would be nice if a solution followed this general pattern of interacting with a database:
Note: the strSportSQL string is actually all on one line, this forum displays it differently.
Code:
'Read Sports Dim strSportSQL As String strSportSQL = "SELECT DISTINCT TblSport.sportName FROM TblSport INNER JOIN ((TblLeague INNER JOIN TblLeagueSeason ON TblLeague.leagueID = TblLeagueSeason.leagueID) INNER JOIN TblLeagueSeasonTeam ON TblLeagueSeason.leagueSeasonID = TblLeagueSeasonTeam.leagueSeasonID) ON TblSport.sportID = TblLeague.sportID GROUP BY TblSport.sportName, TblLeague.leagueID, TblLeague.size, TblLeague.leagueName HAVING (((Count(TblLeagueSeasonTeam.teamID))<[size]));" Dim DataConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("App_Data/Database.mdb")) Dim SportCommand As New OleDbCommand(strSportSQL, DataConn) DataConn.Open()
Comment