Recent

Author Topic: Text field showing as blob in DBGrid  (Read 10956 times)

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Text field showing as blob in DBGrid
« on: January 19, 2011, 02:39:15 am »
Has there been any fix to this yet? Is there any way to display the text?
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Text field showing as blob in DBGrid
« Reply #1 on: January 19, 2011, 02:46:32 am »
Not sure what you mean. Are you referring to a bug report?

Thanks.

-Phil

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Re: Text field showing as blob in DBGrid
« Reply #2 on: January 19, 2011, 03:41:48 am »
Not sure what you mean. Are you referring to a bug report?

Thanks.

-Phil

When I fill a DBGrid with a query on a MySQL database, integer and date fields show correctly but text fields show as "(blob)". I was wondering if there is a way to have text fields displayed correctly. Googling showed this had been a problem in the recent past and I was wondering whether there is a solution yet.
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Text field showing as blob in DBGrid
« Reply #3 on: January 19, 2011, 03:54:36 am »
Are you using the components from the SQLdb tab? That's a separate package, I think.

I haven't used MySQL, but those components work with Sqlite text fields (VARCHAR).

Thanks.

-Phil



dkjMusic

  • Full Member
  • ***
  • Posts: 146
Re: Text field showing as blob in DBGrid
« Reply #4 on: January 19, 2011, 04:10:35 am »
Are you using the components from the SQLdb tab? That's a separate package, I think.

I haven't used MySQL, but those components work with Sqlite text fields (VARCHAR).

Thanks.

-Phil

Yes, I'm using the SQLdb components. If DBGrid will display SQLite text fields, I'll check it out. Thanks for your input.

That is, if I can figure out why I get "/usr/bin/ld: cannot find -lsqlite" when I try to install the SQLite packages. %)
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Text field showing as blob in DBGrid
« Reply #5 on: January 19, 2011, 04:24:40 am »
I created my Sqlite database from XML and in the code for doing that I find this comment:

"Note can't use TEXT or REAL as data type for some reason with TSqlite3Dataset".

That's why I created the text fields a VARCHAR. Maybe that limitation has something to do with your problem as well.

I'm on Mac, where all Macs have Sqlite already installed, so I don't think I can help you much with installing it.

Thanks.

-Phil

Lacak2

  • Guest
Re: Text field showing as blob in DBGrid
« Reply #6 on: January 20, 2011, 07:32:36 am »

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Re: Text field showing as blob in DBGrid
« Reply #7 on: January 20, 2011, 12:41:24 pm »
This problem was already discussed :
http://lazarus.freepascal.org/index.php/topic,5321.msg56151.html#msg56151
I know. That's why my post asked "Has there been any fix to this yet?"

Anyway, Phil's replies got me to look at SQLite. I was using a MySQL database, converted from MSAccess with Kexi, and I'm now using a SQLite version and don't have to mess with a server and user account administration. PLUS the Sqlite3Dataset1 with DBGrid now shows the Text fields just fine, which solves my original problem. Thanks to Phil for putting me on the right track.

I'm new to Lazarus and database programming and appreciate the help from all of you.
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

cpalx

  • Hero Member
  • *****
  • Posts: 652
Re: Text field showing as blob in DBGrid
« Reply #8 on: January 20, 2011, 03:54:37 pm »
cast your field

do something like this:

select cast(yourfield as varchar) as name from table

that will solve your problem

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Text field showing as blob in DBGrid
« Reply #9 on: January 20, 2011, 04:28:05 pm »
Does that work with Sqlite too? That might explain why I couldn't use TEXT fields.

Thanks.

-Phil

jamj

  • Newbie
  • Posts: 1
Re: Text field showing as blob in DBGrid
« Reply #10 on: February 20, 2011, 12:03:10 pm »
I had the same problem. Finally I have solved the problem.  :D

For some reason the mysql components do not realize that text and blob data are diferent so for the libraries is the same type.

When you receive the "blob" the data is still there, you only have to extract the data with a cast. I did this to get the data:

var
e : string;

begin
  e:= MY_QUERY.Fields[1].AsString;

Where "fields
  • " represents the colum 1 data. MY_QUERY is a TSQLquery component.






 

TinyPortal © 2005-2018