Forum > Databases

[solved] MySQL table field defined as Char(1)

(1/4) > >>

jcmontherock:
Hello,
I have a MySQL table which contains a field defined as Char(1). I use TSQLQuery to select data. To get the field value I am using:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---String := SQLQuery.Fields[Column].AsString This does not work: the return value is empty. There is no "AsChar" property. Is somebody knows how to do that ?

Zvoni:
What's your SELECT look like?

jcmontherock:
SELECT * FROM datable;

dseligo:

--- Quote from: jcmontherock on May 03, 2022, 11:35:36 am ---SELECT * FROM datable;

--- End quote ---

Now Zvoni will tell you that you shouldn't use 'select *'.  :)

But that isn't your problem.
I use char(1) all the time and it works perfectly well.
Show more code, this surely isn't your code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---String := SQLQuery.Fields[Column].AsString
You don't have variable named 'String' and you are missing semicolon at the end.
So, show your actual code, it will help to spot your error.

dseligo:

--- Quote from: jcmontherock on May 03, 2022, 11:24:25 am ---This does not work: the return value is empty.

--- End quote ---

One more thing: are you absolutely sure you have something written in the that field? Maybe the field is empty in the database (i.e. you didn't insert anything in that field).

Navigation

[0] Message Index

[#] Next page

Go to full version