14 Replies - 661 Views - Last Post: 22 September 2012 - 08:44 PM Rate Topic: -----

#1 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Help Saving Panels To Database

Posted 21 September 2012 - 05:41 PM

Hello,

I think that in this particular case the title might explain itself but I will go into more detail anyway. I am trying to save a panel that contains hundreds of images to a database.

Is this possible?
If not, is their a way around this?

Thanks in advance guys, I really appreciate this.

Thanks,
Matt
Is This A Good Question/Topic? 0
  • +

Replies To: Help Saving Panels To Database

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,461
  • Joined: 12-June 08

Re: Help Saving Panels To Database

Posted 21 September 2012 - 05:47 PM

Ideally you would save the images to the database and tie them to a unique key for that panel.

The actual image or a location to the image.. and the specifics of how the image is displayed in the panel.
Was This Post Helpful? 0
  • +
  • -

#3 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Re: Help Saving Panels To Database

Posted 22 September 2012 - 04:44 AM

View Postmodi123_1, on 21 September 2012 - 05:47 PM, said:

Ideally you would save the images to the database and tie them to a unique key for that panel.

The actual image or a location to the image.. and the specifics of how the image is displayed in the panel.


Would I then need to create hundreds of database columns to accommodate for the images or would this be achieved by using the unique key?

Thanks for your help by the way man :)
Was This Post Helpful? 0
  • +
  • -

#4 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Re: Help Saving Panels To Database

Posted 22 September 2012 - 09:35 AM

Hello,

I am currently creating a level editor using visual studio 2010. So far it is pretty simple, the form is covered in controls called (Tiles) and when you click on the control you place an image. That bit was pretty simple. My problem is that I would like to be able to save the levels you created.

Currently, I am using databases to keep all of the map names ect - but how would I go about saving all of these controls to a database?

If somebody could walk me through it then it would be much appreciated,

Thanks,
Matt

P.S if you would like an image of the form with all of the tile controls on then please ask :)
Was This Post Helpful? 0
  • +
  • -

#5 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 10:10 AM

My approach would be to map the location of the tiles to the DB in a game table. Then when you load the game you create the tiles and load the images to the right control.
Was This Post Helpful? 0
  • +
  • -

#6 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Re: Help Saving Panels To Database

Posted 22 September 2012 - 11:02 AM

View Post_HAWK_, on 22 September 2012 - 10:10 AM, said:

My approach would be to map the location of the tiles to the DB in a game table. Then when you load the game you create the tiles and load the images to the right control.


First of all, thanks again for helping me again Hawk. Secondly, it appears to be slightly more complex than this because the user chooses the pictures so it is not loading the same image in every tile,
Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 11:14 AM

No problem. So you have a table of images with a relationship to the game table. In each tile you have the coordinates/location and the image id. Are you familiar with a relational database?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,461
  • Joined: 12-June 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 11:38 AM

I don't see why you would need hundreds of columns... one column that is the byte array of the image or the location of the image.. a few columns for that image's location, size, and other display junk.. a unique key for the row.. and a key for the specific panel it is tied to. Then you just insert rows for each image.
Was This Post Helpful? 0
  • +
  • -

#9 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Re: Help Saving Panels To Database

Posted 22 September 2012 - 11:46 AM

View Post_HAWK_, on 22 September 2012 - 11:14 AM, said:

No problem. So you have a table of images with a relationship to the game table. In each tile you have the coordinates/location and the image id. Are you familiar with a relational database?


Pretty much, I have a single panel full of controls that contain 1 picturebox. When a user clicks on the control inside the panel it places an image so the tiles themselves are not on the same form. Unfortunately I am not familiar with a relational database; I tend to program right down to the bone so I tend to stay clear of databases but unfortunately they are a requirement for this level editor.

Thanks again for your help man,
How would I go about using the relational database?

Sorry for the questions,
Matt

The image attached shows two tiles that have been placed on the map (the map is a panel) but now i need a way to save them so when i next load the form they will load from a database and be there :)Attached Image
Was This Post Helpful? 0
  • +
  • -

#10 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Re: Help Saving Panels To Database

Posted 22 September 2012 - 12:07 PM

View Postmodi123_1, on 22 September 2012 - 11:38 AM, said:

I don't see why you would need hundreds of columns... one column that is the byte array of the image or the location of the image.. a few columns for that image's location, size, and other display junk.. a unique key for the row.. and a key for the specific panel it is tied to. Then you just insert rows for each image.


Stupid question, How would I go about doing this via code?
Was This Post Helpful? 0
  • +
  • -

#11 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 12:33 PM

You should read up on the subject - it will greatly help your case. Example of relational database:

Table[game] //4x4 grid
  Player, String  
  Level, Int
  Grid0PicId, Int
  Grid1PicId, Int
  Grid2PicId, Int
  Grid3PicId, Int
End table


Table[GridPic]
  GridPicId, Int
  Img, [Image|varbinary(MAX)|String]  //pick datatype that fits your needs
End Table


If you use a string for the Img field you could just be storing the image files and loading them from a directory.

Now when you store Grid0PicId as 3 the return is the Img field from same table. This way your Level table is only storing a Int datatype for each grid and game which will improve DB performance and keep it's size down as the images are stored in only one place - reducing duplication.

This post has been edited by _HAWK_: 22 September 2012 - 01:40 PM

Was This Post Helpful? 0
  • +
  • -

#12 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,461
  • Joined: 12-June 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 12:47 PM

Doing what via code? You set up the tables in your database management admin panel (depending on what you are using)... and then you check out the VB.NET tutorials we have on how to interact with the database.. a few command objects and a connection string later and you are set!
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,461
  • Joined: 12-June 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 01:22 PM

Merging duplicate posts.. let's not do that again.
Was This Post Helpful? 0
  • +
  • -

#14 steadi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-July 12

Re: Help Saving Panels To Database

Posted 22 September 2012 - 01:43 PM

View Postmodi123_1, on 22 September 2012 - 01:22 PM, said:

Merging duplicate posts.. let's not do that again.


I agree it seems to have messed up the one we had going, I agree let's not merge duplicate posts. Anyhow, thanks for the answers guys - I will begin development with releational tables as soon as I get back to my work pc.

Thanks
Was This Post Helpful? 0
  • +
  • -

#15 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,461
  • Joined: 12-June 08

Re: Help Saving Panels To Database

Posted 22 September 2012 - 08:44 PM

*sigh* No.. I mean for you to not create duplicate topics.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1