06-12-2007, 06:41 PM | #1 | ||
College Prospect
Join Date: Jul 2001
Location: Nebraska
|
Another couple of Visual Basic Questions
1) I need to update a specific column and record in access from a label on my form. Is there any way of doing this..???
2) How do you disable buttons until certain conditions are met? Example; I want my load game button to be grayed out until there is a saved game available. 3) What would be the best way to create a template for a new game, so I could have multiple saved games.. Plus, I'm really having problems saving info on my form back to my database.. I appreciate any and all help you guys give me.. Thanks again..
__________________
JJ Smitty Owner of the TheC.F.L. - Come by and check us out. |
||
06-12-2007, 06:51 PM | #2 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
I'm strictly an amateur, so with that in mind:
1) Can't really help you with HOW to do this, but it's certainly possible. 2) You'd need a condition that runs when the main form is loaded that checks if a save game exists. If so, enable the load button. 3) Well, you'd need to write every variable stored in your game to a file (score, money, experience, whatever). Then when you load, you populate the variables with those stored in the file.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
06-12-2007, 08:37 PM | #3 |
High School JV
Join Date: Jun 2006
Location: Tampa, FL
|
You didn't specify what programming enviroment you are using (VBA, VB6, .NET 2003, .NET 2005, etc.) I need more info in order to help you.
__________________
ShaneTheMaster GM, Savannah Kings (WOOF2) Ex-GM, Austin Rage (USFL) Ex-GM, Cincinatti Bengals, (Replicated NFL) Ex-GM, Tampa Bay Surge, (WLAF) |
06-12-2007, 08:50 PM | #4 | |
College Prospect
Join Date: Jul 2001
Location: Nebraska
|
Quote:
vb 2005
__________________
JJ Smitty Owner of the TheC.F.L. - Come by and check us out. |
|
06-12-2007, 09:14 PM | #5 | |
High School JV
Join Date: Jun 2006
Location: Tampa, FL
|
Quote:
1. There is no short answer to this, but you basically need to create a Binding Data Source to your table, which has to have a primary key specified. Then, after specifying the DataSource and Datamember properties of the BindingDataSOurce control (which would be the DB and the table, respectively), a DataAdapter control will atuomatically be generated for the specified table., You then specify a SELECT query, passing in the primary key of the row you want to fill by. You program will then be able to auto generate an UPDATE query that you would use. On your trigger, just update the database via that BindingDataSource. If you don't know what I am talking about, then you need to do some reading on the BindingDataSource control. 2. cmdButton.enabled = False 3. ??????
__________________
ShaneTheMaster GM, Savannah Kings (WOOF2) Ex-GM, Austin Rage (USFL) Ex-GM, Cincinatti Bengals, (Replicated NFL) Ex-GM, Tampa Bay Surge, (WLAF) Last edited by ShaneTheMaster : 06-12-2007 at 09:14 PM. |
|
06-12-2007, 10:40 PM | #6 |
Pro Starter
Join Date: Nov 2002
Location: Winnipeg, MB
|
1) The first one is a doozy, there are a lot of different ways to acheive this. My personal preference is to use codesmith to do all of the grunt work (CSLA.NET templates are nice) of generating classes for data access based on your existing table structure, and then just databind to the objects that you fetch. Codesmith can even generate your stored procedures. This may be a more advanced approach then you are looking for though. For what is likely a simpler answer (with a guide), check out this link: http://www.15seconds.com/issue/040614.htm
2) The basic answer is setting the Enabled property to false as ShaneTheMaster lists above. You may quickly run into messy 'spaghetti' logic if you end up with a lot of different conditions controlling that state. If you do find your control over this becoming an issue, take a look at the Observer pattern for a more advanced method of controlling state behaviour (http://en.wikipedia.org/wiki/Observer_pattern). 3) Groundhog probably covers this in the best manner possible without any of us actually knowing anything about how your application is structured. Hope this helps, if any of this is too advanced just ignore what you don't understand for now.
__________________
"Breakfast? Breakfast schmekfast, look at the score for God's sake. It's only the second period and I'm winning 12-2. Breakfasts come and go, Rene, but Hartford, the Whale, they only beat Vancouver maybe once or twice in a lifetime." Last edited by Fidatelo : 06-12-2007 at 10:43 PM. Reason: inserted a better link for explaining the observer pattern |
06-12-2007, 10:59 PM | #7 |
Favored Bitch #1
Join Date: Dec 2001
Location: homeless in NJ
|
i feel dumb reading this
|
06-13-2007, 08:30 AM | #8 | |
College Prospect
Join Date: Jul 2001
Location: Newcastle, Australia
|
Quote:
Code:
I'd recommend having a look at this page for more help with SQL. http://www.highcroft.com/highcroft/sql_intro.pdf |
|
06-13-2007, 10:17 AM | #9 | |
Pro Starter
Join Date: Nov 2002
Location: Winnipeg, MB
|
Quote:
This type of code is very much old-school VB6 code, and should be moved away from when possible. The preferred .NET way of writing an inline SQL statement like above would be as follows: txtSQL = String.Format("INSERT INTO Slips VALUES ({0}, '{1}', '{2}', #{3}#)", txtID, lstSlip.Text, txtName, datevar.ToString("mm/dd/yyyy")) Further to this, hungarian notation (txtSQL, lstSlip, etc) should be replaced with camel casing (sql, slipListBox) when naming variables (see http://msdn.microsoft.com/library/de...guidelines.asp for more details on naming conventions). Finally, in most cases I would recommend using a stored procedure over inline SQL.
__________________
"Breakfast? Breakfast schmekfast, look at the score for God's sake. It's only the second period and I'm winning 12-2. Breakfasts come and go, Rene, but Hartford, the Whale, they only beat Vancouver maybe once or twice in a lifetime." |
|
06-13-2007, 10:18 AM | #10 |
Pro Starter
Join Date: Nov 2002
Location: Winnipeg, MB
|
dola
When writing VB.NET code, avoid using the "&" character for concatenating strings, it is only there for backwards compatability. The proper .NET method for concatenating strings is to use the "+" character.
__________________
"Breakfast? Breakfast schmekfast, look at the score for God's sake. It's only the second period and I'm winning 12-2. Breakfasts come and go, Rene, but Hartford, the Whale, they only beat Vancouver maybe once or twice in a lifetime." |
06-13-2007, 01:15 PM | #11 | |
Pro Starter
Join Date: Jul 2003
Location: South Bend, IN
|
Quote:
__________________
Hattrick - Brays Bayou FC (70854) / USA III.4 Hockey Arena - Houston Aeros / USA II.1 Thanks to my FOFC Hattrick supporters - Blackout, Brillig, kingfc22, RPI-fan, Rich1033, antbacker, One_to7, ur_land, KevinNU7, and TonyR (PM me if you support me and I've missed you) |
|
06-13-2007, 01:19 PM | #12 | |
Pro Starter
Join Date: Nov 2002
Location: Winnipeg, MB
|
Quote:
Given that he is learning, he may as well learn to do things according to standard. It is much easier to learn it right the first time then to develop habits and have to un-learn them later.
__________________
"Breakfast? Breakfast schmekfast, look at the score for God's sake. It's only the second period and I'm winning 12-2. Breakfasts come and go, Rene, but Hartford, the Whale, they only beat Vancouver maybe once or twice in a lifetime." |
|
06-13-2007, 02:49 PM | #13 |
College Prospect
Join Date: Jul 2001
Location: Nebraska
|
WOW, lot's of great idea's. Thanks guys, you have been a big help but i'm still stuck.
What I'm doing is trying to create a simple game and update the info back to a access database. What happens is, the loop runs and creates a value then displays it to a label on my form, I would like to update that value to the database. I can open a connection to my database, but then I get lost about the FILL command to the datadapter and how to update that data back to my database with the new value from my form.. Does that help..???
__________________
JJ Smitty Owner of the TheC.F.L. - Come by and check us out. |
06-13-2007, 09:44 PM | #14 |
Pro Starter
Join Date: Nov 2002
Location: Winnipeg, MB
|
Check out this site: http://authors.aspalliance.com/quick...c/default.aspx
It seems to have a lot of tutorials. I won't vouch for the quality, but it seems to cover the basics (data access, data binding, etc). Also, never forget MSDN (http://msdn2.microsoft.com/en-us/default.aspx). There is a LOT of info there.
__________________
"Breakfast? Breakfast schmekfast, look at the score for God's sake. It's only the second period and I'm winning 12-2. Breakfasts come and go, Rene, but Hartford, the Whale, they only beat Vancouver maybe once or twice in a lifetime." |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|