• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1350
  • Last Modified:

BC30518: Overload resolution failed because no accessible '>' can be called with these arguments: 'Public Shared Operator >(t1 As Date, t2 As Date) As Boolean': Value of type 'Class1.Results' cannot b

help..im getting BC30518: Overload resolution failed because no accessible '>' can be called with these arguments: 'Public Shared Operator >(t1 As Date, t2 As Date) As Boolean': Value of type 'Class1.Results' cannot be converted to 'Date'.


for

If Newposts(myname) > DateTime.Now Then

Open in new window

hared Function Newposts(ByVal name As Boolean) 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
        Try
            con.Open()
            Dim theres As Results
            cmd.CommandText = "Select TOP 1  Format(lasttime, 'dd/mm/yyyy hh:mm:ss') from forum where Auther = name order by lasttime DESC"
            theres = cmd.ExecuteScalar()
            Return theres
        Catch ex As Exception
            Throw ex
        Finally
            con.Close()
        End Try
    End Function

Open in new window

0
runnerjp2005
Asked:
runnerjp2005
  • 10
  • 10
1 Solution
 
CodeCruiserCommented:
You are only returning a single value in this function so you dont need to use the structure

Shared Function Newposts(ByVal name As Boolean) As Date
        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
        Try
            con.Open()
            Dim theres As Date
            cmd.CommandText = "Select TOP 1  Format(lasttime, 'dd/mm/yyyy hh:mm:ss') from forum where Auther = name order by lasttime DESC"
            theres = cmd.ExecuteScalar()
            Return theres
        Catch ex As Exception
            Throw ex
        Finally
            con.Close()
        End Try
    End Function
0
 
runnerjp2005Author Commented:
ahh so i should have used date

i now get onversion from string "20/04/2011 12:55:59" to type 'Boolean' is not valid.
0
 
CodeCruiserCommented:
Are you getting this error on same line?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
runnerjp2005Author Commented:
yes on here  If Newposts(myname) > DateTime.Now Then
0
 
CodeCruiserCommented:
Try using

If DateTime.ParseExact(Newposts(myname), "dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture
)  > DateTime.Now


Also, you are using "Format(lasttime, 'dd/mm/yyyy hh:mm:ss')" in your query. It shoud be

Format(lasttime, 'dd/MM/yyyy hh:mm:ss')

as mm is for minutes not month.
0
 
runnerjp2005Author Commented:
is it because my time layout looks like this 03/12/2011 07:47:13
but DateTime.Now is 03/12/2011 07:47:13 AM
0
 
CodeCruiserCommented:
Should not matter.

You can try this

If DateTime.ParseExact(Newposts(myname), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture
)  > DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture)


Also change
Format(lasttime, 'dd/MM/yyyy hh:mm:ss')
to
Format(lasttime, 'dd/MM/yyyy HH:mm:ss')
0
 
runnerjp2005Author Commented:
if i do that myname and culture info is not decleared
0
 
CodeCruiserCommented:
What are you actually trying to do?
0
 
runnerjp2005Author Commented:
ok so what im trying to do is this:

in my forum db i have 3 fields which im trying to check , these are Auther , Posttime and lasttime

i want to display an image if there has been a post between the last time the user has logged in and now

0
 
runnerjp2005Author Commented:
just to add i use membership system in vb.net so i cant get username via Membership.GetUser.UserName
0
 
CodeCruiserCommented:
Ok try using this

Shared Function Newposts(ByVal name As Boolean) As Date
        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
        Try
            con.Open()
            Dim theres As Date
            cmd.CommandText = "Select TOP 1  lasttime from forum where Auther = name order by lasttime DESC"
            theres = cmd.ExecuteScalar()
            Return theres
        Catch ex As Exception
            Throw ex
        Finally
            con.Close()
        End Try
    End Function




with

If Newposts(myname) > DateTime.Now Then
0
 
runnerjp2005Author Commented:
now i get Conversion from string "runnerjp" to type 'Boolean' is not valid.
0
 
CodeCruiserCommented:
Where is the runnerjp coming from? Show the latest code.
0
 
runnerjp2005Author Commented:
It gets runnerjp jp from

   Dim myname As String = Membership.GetUser.UserName
            If Newposts(myname) > DateTime.Now Then

then i just used what u added
0
 
CodeCruiserCommented:
Ok try this

Dim myname As String = Membership.GetUser.UserName
Dim LastDate As Date = NewPosts(myname)
            If LastDate > DateTime.Now Then
0
 
CodeCruiserCommented:
By the way, how can the last post be in future?
0
 
runnerjp2005Author Commented:
Im now using:

Shared Function Newposts(ByVal name As String) As Date
        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
        Try
            con.Open()
            Dim theres As Date
            cmd.CommandText = "Select TOP 1  lasttime from forum where Auther = runnerjp order by lasttime DESC"
            theres = cmd.ExecuteScalar()
            Return theres
        Catch ex As Exception
            Throw ex
        Finally
            con.Close()
        End Try
    End Function

Dim myname As String = Membership.GetUser.UserName
Dim LastDate As Date = NewPosts(myname)
            If LastDate < DateTime.Now Then


but im getting no value given in one of the paramiters but a cant see where its not getitng the value as i have stepped through the code and it seems fine
0
 
CodeCruiserCommented:
Oh dear. Why are you using this?

cmd.CommandText = "Select TOP 1  lasttime from forum where Auther = runnerjp order by lasttime DESC"

Why not

cmd.CommandText = "Select TOP 1  lasttime from forum where Auther = '" & Name & "' order by lasttime DESC"

???
0
 
runnerjp2005Author Commented:
Hey i think i have code working now you pointed this out lol thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 10
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now