Member_2_5230414
asked on
Counting rows in access db...
I currently have this code
i have 3 options i use to get no of threads from different forums
Dim Res As Results = Class1.noposts("general")
threads.Text = Res.Result1
Dim Res As Results = Class1.noposts("races")
threads.Text = Res.Result1
Dim Res As Results = Class1.noposts("info")
threads.Text = Res.Result1
now could i add all 3 together without changing the code above or would i have to re-write the code?
Shared Function noposts(ByVal forumname As String) As Results
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\perkinj\My Documents\Visual Studio 2010\WebSites\runningprofiles\forums\forum.mdb;")
Dim cmd As New OleDbCommand
cmd.Connection = con
cmd.Parameters.AddWithValue("@forumname", forumname)
Try
con.Open()
cmd.CommandText = "Select Count(*) From forum where Forum =@forumname"
Dim Res As Results
Res.Result1 = cmd.ExecuteScalar()
cmd.CommandText = "Select Count(*) From forum where Forum =@forumname and numrep = 0 "
Res.Result2 = cmd.ExecuteScalar()
cmd.CommandText = "Select TOP 1 title + '|' + LastPoster +'|' + Format(lasttime, 'dd/mm/yyyy hh:mm:ss') from forum where Forum =@forumname AND numrep = 0 order by lasttime DESC"
Res.Result3 = cmd.ExecuteScalar()
Return (Res)
Catch ex As Exception
Throw ex
Finally
con.Close()
End Try
End Function
i have 3 options i use to get no of threads from different forums
Dim Res As Results = Class1.noposts("general")
threads.Text = Res.Result1
Dim Res As Results = Class1.noposts("races")
threads.Text = Res.Result1
Dim Res As Results = Class1.noposts("info")
threads.Text = Res.Result1
now could i add all 3 together without changing the code above or would i have to re-write the code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window