Firstly this will be a short post just explaining how to create a connection to a database from a c# application and how to make a simple select statement run and show results.
Tools:
Microsoft Access 2013 (MA)
Visual studio 2010 (VS)
Firstly open VS and create a new windows application.
Go into the code view and add the following to the list of using statements:
using System.Data.OleDb;
The next part is to create a oledb connection to allow us to connect to the database, I have created mine as to make it a global connection allowing anything on the form to access it. The code for this looks like this:
OleDbConnection connection = new OleDbConnection();
And it is placed at the beginning of the program, like so:
I have also added the code that is on line 20, this is the connection string and is supplied with the path file name of where your database is located on your machine.
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Insert path file here;Persist Security Info=False;";
Changing the bold text to your file path will allow your program to find your database and connect to it. The connection string may differ on different versions of software as well as between different software, to check use this website:
http://www.connectionstrings.com/
Next create a form load event by going to the GUI part of the form and double clicking somewhere on the form, you will be returned to the code view but with an event created; this will run whenever the form is loaded.
Add the following try catch statement to your newly created event:
This try catch statement will attempt to connect to your chosen database and if it cannot it will display the error preventing it in a message box. For example if I incorrectly type the file path for the connection string this error will appear:
Line 27 opens the connection that was established at the beginning of the program.
Line 28 changes the text for a label I have placed on the form to display the connection status, it is not needed for the program to work but I found it useful whilst I'm working on the program. It is also worth noting that line 27 and line 39 are the only ones of the try statement required to open and close a connection to the database and that everything else in between is there for the SELECT statement.
Line 29 creates the command object used to execute the SELECT statement.
Line 30 assigns the connection string to the command object so it knows which connection to execute on.
Line 31 creates the string query that will be executed. Mine is just a simple Select statement that gets everything from a table called 'game' in my database,
Line 32 assigns the query to the command so it knows what it is executing.
Line 34 creates a data table adapter object and passes the command as its parameter.
Line 35 creates a data table object.
Line 36 fills the data table with the results of the command that was passed to the adapter. So currently it fills it with all the data found in the 'game' table.
Line 37 assigns the data table object to a data grid view object on the form called DGV_databaseWindow.
Line 39 closes the connection to the database. I've read its good practice to close any connection after your done but I'm not sure if it actually prevents errors or just an extension of some programming structure guidelines.
Line 41- 44 is just the catch statement that was explained earlier and displays an error if one is encountered.
Next add a data grid view control to the GUI part of your form (found in toolbox) and change its name to DGV_databaseWindow,
As long as you've created your database and its where the file path suggests it is everything should run fine and you should get a screen like this:
So if anyone besides me is reading this and has any questions, feel free to contact me and i'll try and answer the best I can.
FF10 - Guadosalam
Forever Compiling
Sunday, 31 May 2015
Thursday, 20 November 2014
Creating a new map in RPG Maker VX Ace
This will show how I created a map in rpg maker vx ace.
To create a new map you'll need to right click either the project or one of the maps that you already have in the bottom left window and select the 'New Map' option. Alternatively this can be done by clicking either one of the maps or the project and pressing the 'insert' button.
This brings up the map properties window for the map you just created.
Name: this is the name that it will be referred to by the application and can be as specific/ unreadable as you like.
Display name: this is the name that appears when a user enters the area and should be whatever you want the game to refer to it as.
Tileset: this determines what tiles can be used to make your map. the field tileset that has been selected in the image will mostly contain things that will be associated with an outdoors area on the world map. It is possible to mix and match or t use your own tiles by adding them to the database.
Width and Height: this determines how many tiles across and down your map will be. Just to point out that 000,000 , which is the starting tile, will be in the top left.
Scroll Type: I haven't used this yet so I'm not 100% sure. according to the documentation it sound like it makes a map like a circle/sphere so if you go far enough to the left you can end up on the right.
Specify Battleback: Allows you to specify a battle background; both the floor and the sky allowing for some awesome combinations. If no battleback is specified then one match this environment will be generated.
Auto-Change BGM: Allows a specific background music track to be played when player is on the map.
Auto-Change BGS: Allows a specific background sound to be played when the player is on the map.
Disable dashing: Stops the player from dashing while on this map.
Parallax background: this is the background that will appear behind the tiles and will be seen when tiles aren't laid down. I havent personally used it yet but the looping allows is to be repeated in which ever direction is needed; either horizontal, vertical or both. 'Show in the Editor' I assume toggles it on/off whilst in the editor mode.
Note: Allows notes to be written down. personally I plan to use it as either a summary of content on the map or a list of to do's for the map.Either way it has no impact on anything and is just for referential purposes.
Encounters:This is where you set up what encounters will appear on each map. Encounters are with troops not individual enemies. This will make more sense later on when I explain how to set up new enemies. The 'Steps Average' determines the average amount that is needed for a random battle encounter to occur.
Once all is done and set up hit the 'OK' button.
Now the map will look like this when you start so just click on a tile from the top left window and the click a square on the map to copy and paste the tile in to make your map.
that's the basics of making a map.
To edit a map's properties you need to click the map you want to change and then either right click it and select map properties from the drop down or click the map and press 'spacebar'.
Here's the start of my world map at the moment.
Hope this has been helpful and I leave you with this.
FF9 - Vivi's theme
To create a new map you'll need to right click either the project or one of the maps that you already have in the bottom left window and select the 'New Map' option. Alternatively this can be done by clicking either one of the maps or the project and pressing the 'insert' button.
This brings up the map properties window for the map you just created.
Name: this is the name that it will be referred to by the application and can be as specific/ unreadable as you like.
Display name: this is the name that appears when a user enters the area and should be whatever you want the game to refer to it as.
Tileset: this determines what tiles can be used to make your map. the field tileset that has been selected in the image will mostly contain things that will be associated with an outdoors area on the world map. It is possible to mix and match or t use your own tiles by adding them to the database.
Width and Height: this determines how many tiles across and down your map will be. Just to point out that 000,000 , which is the starting tile, will be in the top left.
Scroll Type: I haven't used this yet so I'm not 100% sure. according to the documentation it sound like it makes a map like a circle/sphere so if you go far enough to the left you can end up on the right.
Specify Battleback: Allows you to specify a battle background; both the floor and the sky allowing for some awesome combinations. If no battleback is specified then one match this environment will be generated.
Auto-Change BGM: Allows a specific background music track to be played when player is on the map.
Auto-Change BGS: Allows a specific background sound to be played when the player is on the map.
Disable dashing: Stops the player from dashing while on this map.
Parallax background: this is the background that will appear behind the tiles and will be seen when tiles aren't laid down. I havent personally used it yet but the looping allows is to be repeated in which ever direction is needed; either horizontal, vertical or both. 'Show in the Editor' I assume toggles it on/off whilst in the editor mode.
Note: Allows notes to be written down. personally I plan to use it as either a summary of content on the map or a list of to do's for the map.Either way it has no impact on anything and is just for referential purposes.
Encounters:This is where you set up what encounters will appear on each map. Encounters are with troops not individual enemies. This will make more sense later on when I explain how to set up new enemies. The 'Steps Average' determines the average amount that is needed for a random battle encounter to occur.
Once all is done and set up hit the 'OK' button.
that's the basics of making a map.
To edit a map's properties you need to click the map you want to change and then either right click it and select map properties from the drop down or click the map and press 'spacebar'.
Here's the start of my world map at the moment.
FF9 - Vivi's theme
A fresh start!
This will primarily be a written recording of the work I'm doing so i can use it as a reference guide in case I do anything like it again.
I'm using RPG Maker VX Ace from steam to construct a small simple role playing game using built in art assets. The main goal of this project is to get comfortable with game design and/or programming applications again.
The structure of each post will likely play out like a how to guide with screenshots detailing each stage of it; hopefully not only myself will get something from it.
And I'll end the post with any resources or websites used for reference.
..... then leave the song that was playing when I finished the post :).
Sacred Ground Esto Gaza - FF9
I'm using RPG Maker VX Ace from steam to construct a small simple role playing game using built in art assets. The main goal of this project is to get comfortable with game design and/or programming applications again.
The structure of each post will likely play out like a how to guide with screenshots detailing each stage of it; hopefully not only myself will get something from it.
And I'll end the post with any resources or websites used for reference.
..... then leave the song that was playing when I finished the post :).
Sacred Ground Esto Gaza - FF9
Subscribe to:
Comments (Atom)







