Last post Jan 24, 2012 01:10 PM by RayWind
Jan 18, 2012 06:39 PM|RayWind|LINK
I've created a few tables in my SQL db that I would like to read values from and use within a web application, specifically I've created a usersProfile table that I'm wanting to write life time statistics and a point amount per user. By mapping this tables
PK to the aspnet_Users table UserId I've created a way to call this table via the current logged in user. Great. I think.
But here's my issue what I want to do is use sql statements to retrieve that data and model it within my application. I'm as green as you can get and don't know what object I'm trying to build. From the tutorials around they all seem to refer to DataSet
objects and DataView objects and all sorts of corresponding classes. I'm sort of unsure of how to ask what I need even. Let me attempt to explain further.
bet() - I need the points total for user to check if has that amount. Wanted to just tie some bets to a dd list for simplicity
won/lost () - call to either subtract points or add, add to lifetime won/lost total
WriteToPoints() - same as win/lost I think
bet() need available amount of course. Has to subtract from user add to pot
reBet() same check, add to pot - all to either subtract points or add, add to lifetime won/lost total
What I'm guessing is -
sub Win Game (wager/pot, currentPointTotal, lifeTimeWinTotal)
pull db into function
Determine which game called?()
add to Points, lifetimeTotal
sub Lose Game (wager/pot, currentPointTotal, lifeTimelossTotal)
subtract from Points, add to lifetimeTotalLosses
The games will just live in a page div and be more logically grouped than architecturally I suppose. This is just an attempt to illustrate what I'm after. From what I've gathered I need to read the table (datareader?) serialize it? construct a sort of user
class from it according to ID logged in, use that data to set that user classes properties, manipulate the properties through "playing" the games, then update the value in the table?
It's all a whirlwind for me and I know it's a broad question and I don't expect anybody to spend a lot of their time to write out a bunch of code for me. I am in need of a little direction however. I have spent a few weeks attempting to figure this out and
have followed a lot of the tutorials I'm not bridging the gap between what they're teaching me and what I need. If there is anything I can provide to help with the question please just reply, thank you for your time in advance!
Jan 19, 2012 08:43 PM|decker dong - msft|LINK
A general idea is that if your game or a project needs to do something with database——CRUD……，I think you'd better use data presentation controls and a datasource control。If you want to write your own methods of CRUD，I think you can bind these methods to
ObjectDataSource and then call it when you need。This is fully automatic and it will remain the maintance，almost no need for you to handle the events or something else to look for that……
For using objectDatasource to make a CRUD，you can have a look at：http://www.codeproject.com/KB/aspnet/ObjectDataSourceInDepth.aspx
Jan 24, 2012 01:10 PM|RayWind|LINK
Thank you for your reply! I'm sorry that it took so long to respond, however we had a giant winter storm here and my power was out for several days. This looks like a really good article I just came back to write a response to thank you before I spend a
while looking that over completely.