Jewtus

SQL Data type from ADO connection

7 posts in this topic

I'm running a query against a DB2 and when I execute it via the terminal access, it works without issue (the field size on the terminal renderer was bumped up to a few thousand to hold all the data). The problem lies when I try to use microsoft query or an ADO connection. It brings back a result that looks like its been encoded or something. Does anyone have any idea or things I can try for troubleshooting?

Share this post


Link to post
Share on other sites



EBCDIC?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

YES! I had no idea what it was called, but based on what wiki says, it looks like that's what I'm dealing with. Can this be handled with an ADO connection or using autoit in anyway?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yeah pretty sure you can do this.

It's the same as converting ASCII, Hex, Bin, etc.

Quick google search even returned some online converters.

>Simple example autoit conversion by nobbe.

Edit: Just out of curiousity, what are you retrieving?

When running queries against *FILE objects I usually don't get my results in EBCDIC.

Edited by Radiance

Share this post


Link to post
Share on other sites

That looks like what I need, but I think I'm missing a step. This is an example of what the data looks like when it comes back from the DB via ADO:

att1s9.jpg

I'm using an ODBC connection to do the ADO query, but when I look at this data on the terminal (in the table and not the setup viewer), I do see the strings that need to be decoded

Share this post


Link to post
Share on other sites

Could you post how you do it?

I'm getting data from DB2 like this.

Maybe it helps you.

Func _DB2Connect($ps_Server, $ps_User, $ps_Pass)
    Local $lo_Connection = ObjCreate("ADODB.Connection")
    $lo_Connection.Provider = "IBMDA400"
    $lo_Connection.Properties("Data Source") = $ps_Server
    $lo_Connection.Properties("User ID") = $ps_User
    $lo_Connection.Properties("Password") = $ps_Pass
    $lo_Connection.Open
    If @error Then Return False

    Return $lo_Connection
EndFunc
 
Func _SQLQuery($po_Connection, $ps_Query, $ps_LogPath = "")
    Local $lsa_Return, $lo_RecordSet
    If $ps_LogPath = "" Then $ps_LogPath = @ScriptDir & "\log"

    $lo_RecordSet = $po_Connection.Execute($ps_Query)
    If @error Then
        ;logging func
        Return False
    EndIf

    If StringMid($ps_Query, 1, 6) <> "SELECT" Then Return True

    $lsa_Return = $lo_RecordSet.GetRows
    If @error Then
        Return False
    EndIf

    Return $lsa_Return
EndFunc

Share this post


Link to post
Share on other sites

I use a DB2 connector and an ODBC connection. Here is the code to open the connection:

$sqlDB2Con = ObjCreate("ADODB.Connection")
$sqlDB2Con.Mode = 16  ; shared
$sqlDB2Con.CursorLocation = 3 ; client side cursor
$sqlDB2Con.Open ("DSN=[ODBC NAME];UID=[USERNAME];Password=[PASSWORD];Database=[DATABASE];Port=[PORT];Hostname=[HOSTNAME];")

and here is the code for a query:

Func __GetRecords($query,$connection)
    $sqlRs = ObjCreate("ADODB.Recordset")
    ConsoleWrite($query&@CRLF)
    $sqlRs.open ($query,$connection)
        If $sqlRs.EOF = True Then
            SetError(1)
            $sqlRs.Close
        Else
            $result = $sqlRs.GetRows
            If UBound($result)>0 Then
                Return $result
                $sqlRs.Close
            Else
                SetError(1)
                $sqlRs.Close
            EndIf
        EndIf
EndFunc

I'll take a look at what you are doing and see if I can adapt it and see if it fixes the issue.

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