Two SQL strings to get two DataTables in one DataSet
I'm trying to pass two SQL strings separated by a semicolon to the database to get two DataTables back in one DataSet, but it throws an error when using the DataAdapter's Fill method saying "Characters found after end of SQL statement." (I modified code I found at http://www.dotnetjunkies.com/tutoria...tutorialid=135)
Here's the code I'm using:
VB Code:
strConn = Session("ConnectString").ToString
strSQL = String.Format("SELECT Sum(tblPlayerGame.Runs) AS SumOfRuns" & _
" FROM tblPlayer INNER JOIN tblPlayerGame ON tblPlayer.PlayerID = tblPlayerGame.PlayerID" & _
" WHERE tblPlayerGame.GameID={0} AND tblPlayer.TeamID={1}", CInt(txtGameID.Text), CInt(txtVisitorTeamID.Text))
strSQL = strSQL & "; " & String.Format("SELECT Sum(tblPlayerGame.Runs) AS SumOfRuns" & _
" FROM tblPlayer INNER JOIN tblPlayerGame ON tblPlayer.PlayerID = tblPlayerGame.PlayerID" & _
" WHERE tblPlayerGame.GameID={0} AND tblPlayer.TeamID={1}", CInt(GameID.Text), CInt(txtHomeTeamID.Text))
ds = DataHandler.GetDataSet(strSQL, strConn)
And here's my DataHandler's GetDataSet method:
VB Code:
Public Shared Function GetDataSet( _
ByVal SQLString As String, ByVal ConnectionString As String) As DataSet
Dim da As OleDbDataAdapter
Dim ds As DataSet
Try
' Create a new DataAdapter
da = New OleDbDataAdapter(SQLString, ConnectionString)
' Fill the DataSet from DataAdapter
ds = New DataSet()
da.Fill(ds)
Catch
Throw
End Try
Return ds
End Function