Recent

Author Topic: [HELP] Connecting to a SQL Database tables?- Console Application  (Read 39332 times)

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #45 on: December 20, 2014, 11:37:47 pm »
Ah okay. What would be the code to display the text from the SQL database? When I'm home I'll make a table called 'message'. Just a simple script to display what's in the SQL table

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #46 on: December 20, 2014, 11:52:07 pm »
I can't completely write all the code for you. If you've already wrote the game you should be able to add some code to simply read out a message-field from the users-table in the code you've already got. If you get in trouble you can post your code here with a clear error message.

You would need some line like this:
Code: [Select]
Message := Query.FieldByName('message').AsString;
right under the premium := line.

After that you can display the message-string to the user just before you jump to your game.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #47 on: December 20, 2014, 11:57:02 pm »
I haven't made the my SQL closed at all yet. How would I add the message first? Thank you!

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #48 on: December 21, 2014, 12:15:56 am »
How would I add the message first?
I'm not sure what you mean. Your question is not very clear.
(You've already made a table for users. You could add a field "message" there to read out by the game. If that's not what you mean please describe in detail what you want.)

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #49 on: December 21, 2014, 12:19:39 am »
that is exactly what I want :) The message will be read out in the console :)

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #50 on: December 21, 2014, 12:21:39 am »
I've made it a varchar and character length is 500. Just want the console application to read the messgge now :)


rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #52 on: December 21, 2014, 12:25:33 am »
Well... I already gave you a line which you need to add in your program (the code I already provided), I even said where to put it, and you can add a line to print the message just before you call your game-procedure. Where are you getting stuck with that?

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #53 on: December 21, 2014, 01:05:45 am »
No I want to change the message. So the message I showed you here http://screenshu.com/static/uploads/temporary/68/f5/jl/42hi29.jpg will display and I can chagne it when I want.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #54 on: December 21, 2014, 01:27:26 am »
What's wrong with changing it in the MySQL-admin program (from which you showed your screenshot)? There is an Edit button there.

If you want YOUR USER/GAMER to be able to change the message then you were not very clear (you asked for "I want to change the message"). So please be very clear and please describe your questions with more detail.

If you want your program/game to be able to change the message (and database) you can look here (or here for the Dutch version). You'll need to present the user with a line to change the message. I assume you can do that yourself (as you've already written a console-game) so if you get stuck with these examples please show us your attempt at the code. (We can't keep writing all the code ourselves).

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #55 on: December 21, 2014, 10:00:46 am »
Sorry for not being clear. I want the message in the database to appear on the console application. Just so when we give our game out to people we can change the message when we want.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #56 on: December 21, 2014, 10:02:10 am »
I'm just confused on how the message will display from the SQL database to the console.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #57 on: December 21, 2014, 10:11:29 am »
Trying to make the message field read into my console application.

Code: [Select]
Query.SQL.Text := 'select * from messages';
  AConnection.Open;
  Query.Open;

Yeah that doesn't work at all. How would I make the message display in the console applicTion?

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #58 on: December 21, 2014, 10:23:14 am »
I already gave you that solution (twice). Please see my previous few posts. You read it out right under the premium := line. Please put my given code in that post in your program.

I did see in your database you have 2 users with the name "test". One with password 0 and one without a password and a message. You should only have one user "test" with a password and message.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: [HELP] Connecting to a SQL Database tables?- Console Application
« Reply #59 on: December 21, 2014, 10:26:58 am »
I'm just confused on how the message will display from the SQL database to the console.
How can you make a console game and be confused as to how to display a string? I've given you the line with which you can read the message in a string. Surely you can make a line to display that string to the console (especially since you've already wrote a console game).

 

TinyPortal © 2005-2018