Front Office Football Central

Front Office Football Central (https://forums.operationsports.com/fofc//index.php)
-   FOFC Archive (https://forums.operationsports.com/fofc//forumdisplay.php?f=27)
-   -   Another couple of Visual Basic Questions (https://forums.operationsports.com/fofc//showthread.php?t=59225)

A-Husker-4-Life 06-12-2007 06:41 PM

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

Groundhog 06-12-2007 06:51 PM

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.

ShaneTheMaster 06-12-2007 08:37 PM

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.

A-Husker-4-Life 06-12-2007 08:50 PM

Quote:

Originally Posted by ShaneTheMaster (Post 1481176)
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.


vb 2005

ShaneTheMaster 06-12-2007 09:14 PM

Quote:

Originally Posted by A-Husker-4-Life (Post 1481117)
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..


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. ??????

Fidatelo 06-12-2007 10:40 PM

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.

Lathum 06-12-2007 10:59 PM

i feel dumb reading this

21C 06-13-2007 08:30 AM

Quote:

Originally Posted by A-Husker-4-Life (Post 1481117)
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..???

Here's the basics of what I've used to input stuff into a database:
Code:

txtSQL = "INSERT INTO Slips VALUES (" & txtID & ",'" & lstSlip.Text & _
"','" & txtName & "',#" & Format(Date, "mm/dd/yyyy") & "#)"
db.Execute txtSQL


I'd recommend having a look at this page for more help with SQL.
http://www.highcroft.com/highcroft/sql_intro.pdf

Fidatelo 06-13-2007 10:17 AM

Quote:

Originally Posted by 21C (Post 1481310)
Here's the basics of what I've used to input stuff into a database:
Code:

txtSQL = "INSERT INTO Slips VALUES (" & txtID & ",'" & lstSlip.Text & _
"','" & txtName & "',#" & Format(Date, "mm/dd/yyyy") & "#)"
db.Execute txtSQL




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.

Fidatelo 06-13-2007 10:18 AM

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.

Mr. Wednesday 06-13-2007 01:15 PM

Quote:

Originally Posted by Fidatelo (Post 1481338)
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).

I'd recommend sticking to what you feel comfortable with, if you're only writing personal code. If you're writing code for an organization, stick to your organization's coding standards.

Fidatelo 06-13-2007 01:19 PM

Quote:

Originally Posted by Mr. Wednesday (Post 1481414)
I'd recommend sticking to what you feel comfortable with, if you're only writing personal code. If you're writing code for an organization, stick to your organization's coding standards.


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.

A-Husker-4-Life 06-13-2007 02:49 PM

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..???

Fidatelo 06-13-2007 09:44 PM

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.


All times are GMT -5. The time now is 07:55 AM.

Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.