Database Querying error.

Started by Striker, Mar 08, 2016, 01:31 PM

Previous topic - Next topic

Striker

I've made this, but it still returns me null :| Why : [?
local q1 = QuerySQL(db, "SELECT Chocolate FROM Accessories WHERE ID ='" + object.ID + "'" );
if ( object.Model == 335 )
{
ClientMessage("You have found a Chocalate! Containing " + GetSQLColumnData( q1, 0 ) + "Vitamins!",player,255,255,0);
QuerySQL(db,"DELETE FROM Accessories WHERE ID = '" + object.ID + "' " );
object.Delete();
}
: [

jayant

One question,is the object custom ?

KAKAN

oh no

Thijn

What returns null?
Is the row actually there? Are you sure you got the right pickup ID? Did you try printing the pickup ID and checking your database?

There's plenty of things you could do yourself to debug this..

Striker

#4
Quote from: Thijn on Mar 08, 2016, 04:59 PMWhat returns null?
Is the row actually there? Are you sure you got the right pickup ID? Did you try printing the pickup ID and checking your database?

There's plenty of things you could do yourself to debug this..
1.Well the query get's simply fail, so whenever any thing that i want to return/get from Database returns null i.e : - ClientMessage("You have found a Chocalate! Containing null Vitamins!",player,255,255,0); also I guess you mean the object ID.
2.I did all before posting, and that's all fine, but still the same problem; however since i'm having multiple objects, so i can't take rowid.

Thijn

Yes, I meant object :)

Try printing the query, and running it yourself using a sqlite browser:
print("SELECT Chocolate FROM Accessories WHERE ID ='" + object.ID + "'");

Striker

Quote from: Thijn on Mar 09, 2016, 06:45 AMYes, I meant object :)

Try printing the query, and running it yourself using a sqlite browser:
print("SELECT Chocolate FROM Accessories WHERE ID ='" + object.ID + "'");
Well, I guess i'm noob myself no? I've created two Tables, with objects IDS, well My English will surely make you confuse, so simply.
I'm having the object with ID 49, and i'm querying the ID 39 .-. I know it's insane, lel, but topic lock. :)