Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Sorting Data.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sorting Data.

 Post Reply Post Reply
Author
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Topic: Sorting Data.
    Posted: 06 June 2005 at 12:11pm
Cry I bet you never expected me to post another question again, right? haha. Okay, here is what I have:
  A GridView that displays 10 Games from the tblGames in the Games db.
  Here is what I need:
  A GridView that displays 10 Games from the tblGames in the Games db if these Games haven't been played within the last 30 days (which is stored in the Games db in the tblLastPlayed).
  Here is my current (and non-working or I wouldn't be posting this) code:
Dim varUserName As String = Profile.UserName.ToString
Dim varDate As Date = Date.Now
varDate.AddDays(-30)
SqlDataSource1.SelectCommand = "SELECT TOP " & CInt(Profile.GamesConfig.NumofGames).ToString() & " ID, Title, Popularity, Type, [Last Played] FROM GAME WHERE '" & varUserName & "' <> LastPlayed.uID AND LastPlayed.LastPlayedDate > '" & varDate & "'"
   My current problem appears to be that LastPlayed.uID and LastPlayed.LastPlayedDate are not bound and cannot be bound. Any help would be appreciated.
David.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2005 at 12:15pm
What error do you get? Or what do you want to do that you don't know how to?
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2005 at 12:45pm
Well, I think I have figured out most of it. Basically, my problem at this point is that the SQL statement doesn't appear capable of comparing two strings to each other using the <> operators. Here is my new code:
SqlDataSource1.SelectCommand = "SELECT TOP " & CInt(Profile.GamesConfig.NumofGames).ToString() & " ID, Title, Popularity, Type, [Last Played] FROM GAME JOIN LastPlayed ON ('" & varUserName & "' <> LastPlayed.uID) AND (LastPlayed.LastPlayedDate > '" & varDate & "')"
I get an error that "The data types varchar and text are incompatible in the not equal to operator."
varUserName is a String and LastPlayed.uID is defined in SQLServer as Text.
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2005 at 1:51pm
I've updated the code once again. This code doesn't throw any errors but doesn't give me any results either:
SqlDataSource1.SelectCommand = "SELECT TOP " & CInt(Profile.GamesConfig.NumofGames).ToString() & " Game.ID, Title, Popularity, Type, [Last Played] FROM GAME JOIN LastPlayed ON ('" & varUserName & "' NOT LIKE LastPlayed.uID)"
What this is supposed to do is show all of the games except for those where there is an entry in the database with the users username, but instead of just removing one or two entries for some reason it is not showing any entries.
David.
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2005 at 3:39pm
Got it all figured out now. Here is the final code:
Dim varNumofGames As String = CInt(Profile.GamesConfig.NumofGames).ToString()
Dim varUserName As String = Profile.UserName.ToString
Dim varDate As Date = Date.Now
varDate.AddDays(-30)
SqlDataSource1.SelectCommand = "SELECT * FROM Game G LEFT OUTER JOIN LastPlayed LP ON G.ID = LP.gID WHERE (LP.gID IS NULL) OR (LP.LastPlayedDate > '" & varDate & "') AND (LP.uID LIKE '" & varUserName & "')"
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.