We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

Member_2_5230414
on
Medium Priority
1,728 Views
Last Modified: 2012-06-22
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

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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

Author

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.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Are you getting this error on same line?

Author

Commented:
yes on here  If Newposts(myname) > DateTime.Now Then
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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.

Author

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
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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')

Author

Commented:
if i do that myname and culture info is not decleared
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
What are you actually trying to do?

Author

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

Author

Commented:
just to add i use membership system in vb.net so i cant get username via Membership.GetUser.UserName
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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

Author

Commented:
now i get Conversion from string "runnerjp" to type 'Boolean' is not valid.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Where is the runnerjp coming from? Show the latest code.

Author

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
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Ok try this

Dim myname As String = Membership.GetUser.UserName
Dim LastDate As Date = NewPosts(myname)
            If LastDate > DateTime.Now Then
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
By the way, how can the last post be in future?

Author

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
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Hey i think i have code working now you pointed this out lol thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.