Jump to content
Sign in to follow this  
rabothole

Blob & mysql

Recommended Posts

rabothole

i'm trying to read data from a blob field in a mysql database but just ge an emty string back,

can someone help please.

Share this post


Link to post
Share on other sites
rabothole

the msgbox gives me no result. thanks or the quick reply.

#include <GUIConstants.au3>
#include <mysql.au3>

Global $sql, $y, $SQL_b_address

connect_db_local()

;~  address is a blob filed in the database

$GetDetail = _Query($sql, "Select physical_addr from branch")
        With $GetDetail
            While Not .EOF
                $y += 0.01
                $SQL_b_address = .Fields("physical_addr" ).value
;               GUICtrlSetData($TxtAddress, $SQL_b_address, "Address")
                MsgBox(0,"Address", $SQL_b_address)
                .MoveNext
            WEnd
            
        EndWith

func connect_db_local()

    Global $ssUsername="root"
    Global $ssPassword="1111"
    Global $ssDatabase="logging"
    Global $ssServer="localhost"
    Global $sDriver = "{MySQL ODBC 3.51 Driver}"
    Global $iPort=3306
    Global $sql = _MySQLConnect($ssUsername, $ssPassword, $ssDatabase, $ssServer, $sDriver, $iPort)
    If @error then
    ProgressOff()
    MsgBox(0,"","error connecting to database")
    Exit
    EndIf

 EndFunc;==>connect_db_local

could you post the code please

Share this post


Link to post
Share on other sites
rabothole

please help, I've search the forum and couldn't find anything.

Share this post


Link to post
Share on other sites
evilskaap

please help, I've search the forum and couldn't find anything.

This is the only result in Google for blob: "blob site:www.autoitscript.com/forum/"

I would also like to see an answer on this.


[font="Lucida Console"]The truth is out there[/font]

Share this post


Link to post
Share on other sites
rabothole

This is the only result in Google for blob: "blob site:www.autoitscript.com/forum/"

I would also like to see an answer on this.

Yes can you see my dilemma ? Still no one ??

Share this post


Link to post
Share on other sites
rabothole

Yes can you see my dilemma ? Still no one ??

can someone just say if I'm an idiot(for asking a dumb question) or something, just something, I still don't know what to do.

Share this post


Link to post
Share on other sites
rabothole

Try

If IsBinary($SQL_b_address) Then
    MsgBox(0,"Address", String($SQL_b_address))
Else
    MsgBox(0,"Address", $SQL_b_address)
EndIf

thanks for the help but still does not return any thing, i thought of doing the following:

Select cast(physical_addr as char) from branch - and running this gave me a result of the address in string that i can use but still done not display anything in Autoit

Share this post


Link to post
Share on other sites
picaxe

Maybe try this in your code to see if anything displays. Nulls are seen by AutoIt as string terminators.

GUICtrlSetData($TxtAddress, StringReplace($SQL_b_address, Chr(0), ""), "Address")

Share this post


Link to post
Share on other sites
rabothole

thanks for the advice but there is a value in the address field in the database i'm 100% sure but even with your line added

it returns nothing not even the default value you assigned, so that means the value is not NULL ? am i right??

Edited by rabothole

Share this post


Link to post
Share on other sites
picaxe

it returns nothing not even the default value you assigned, so that means the value is not NULL ? am i right??

Yes

Share this post


Link to post
Share on other sites
rabothole

Yes

is there a way for me to see the value in AutoIT, I really do not want to change the database we have a web app that runs on there and is functional, i would just like to do an app version of that.

in the mysql.au3 i cannot find anything that resembles blob so i don't think it's written for blob's just the string and int values.

Share this post


Link to post
Share on other sites
picaxe

What is the format of the blob data ?

Share this post


Link to post
Share on other sites
rabothole

What is the format of the blob data ?

this is the way they created the database:

CREATE TABLE `branch` (
  `branch_id` int(12) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL default '',
  `physical_addr` blob,
  `postal_addr` blob,
  `city` varchar(50) default NULL,
  `province` varchar(20) default NULL,
  `phone` varchar(25) NOT NULL default '',
  `fax` varchar(25) default NULL,
  `pcanywhere` varchar(25) default NULL,
  `email` varchar(50) NOT NULL default '',
  `manager_name` varchar(50) default NULL,
  `manager_cell` varchar(20) default NULL,

so i assume that its text, like i said if i run the following on the database i get a resault that is fine:

select cast(physical_addr as char) from branch where branch_id = 10;

i get the result:

JAN PIET STR

WATERKLOOF

PRETORIA

SOUTH AFRICA

Share this post


Link to post
Share on other sites
picaxe

Probably should have suggested this earlier. What does IsString return

With $GetDetail
            While Not .EOF
                $y += 0.01
                $SQL_b_address = .Fields("physical_addr" ).value
;                GUICtrlSetData($TxtAddress, $SQL_b_address, "Address")
                ConsoleWrite("IsString=" & IsString($SQL_b_address) & @LF)
                MsgBox(0,"Address", $SQL_b_address)
                .MoveNext
            WEnd
            
        EndWith

Share this post


Link to post
Share on other sites
rabothole

Probably should have suggested this earlier. What does IsString return

With $GetDetail
            While Not .EOF
                $y += 0.01
                $SQL_b_address = .Fields("physical_addr" ).value
;                GUICtrlSetData($TxtAddress, $SQL_b_address, "Address")
                ConsoleWrite("IsString=" & IsString($SQL_b_address) & @LF)
                MsgBox(0,"Address", $SQL_b_address)
                .MoveNext
            WEnd
            
        EndWith

And this returns IsString=0 and the msgbox empty.

Share this post


Link to post
Share on other sites
rabothole

everything else in this exept the postal_addr (also Blob) returns IsString=1

Share this post


Link to post
Share on other sites
rabothole

Try

ConsoleWrite("DataType=" & VarGetType($SQL_b_address) & @LF)

Thanks so far for the help.

What returned was the following:

DataType=Object

thanks

Edited by rabothole

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.