Avatar billede nielsbkh Nybegynder
18. juli 2005 - 17:28 Der er 7 kommentarer og
1 løsning

Datatypen Notat fejler ved sammenkædning via ODBC med DataFlex

Vi har et produktionssystem som kører på en DataFlex database. I forskellige sammenhænge har jeg brug for at læse data i databasen fra Access. Ved hjælp af en ODBC-driver og datakilde sammenkæder jeg DataFlex tabellerne med Access og tilgår dem ad den vej. Generelt virker det upåklageligt.

Imidlertid er der en tabel, som indeholder et felt af typen notat. Ved sammenkædning med denne tabel er det kun muligt for mig at læse ca. de første 200 tegn i feltet.

ODBC driveren er version 3.10.10.00 fra FLEXquarters dateret 25/02/2003. Access er fra Office 2000.

Er der en måde man kan få fat i de resterende tegn?
Avatar billede terry Ekspert
18. juli 2005 - 18:20 #1
256 characters to be more exact!

Memo fields work fine IN Access but when they are used in other programs then other methods need to be used to read them. They can contain LOTS of data, around 65,000 or more, so you cant just read a memo field as in Access.

You can use the GetChunk method to retrieve a given numbert of bytes from a memo field and then maybe put them in the grid

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthgetchunk.asp
Avatar billede nielsbkh Nybegynder
19. juli 2005 - 07:51 #2
terry ->
Jeg arbejder lidt med dit forslag, men jeg ville gerne se det fulde indhold af feltet i den sammenkædede tabel i Access.
Avatar billede terry Ekspert
19. juli 2005 - 08:28 #3
what do you mean by i den "sammenkædede tabel i Access."?

What application are you using to get the data from Access?
Avatar billede nielsbkh Nybegynder
19. juli 2005 - 08:51 #4
I'm using the danish version of access and don't know what it is called in english.

But if you chose the first menu "Filer" and then the second from the top "Get extern data" and then the second from the top again "connect tables??????" or something. Then I use my ODBC data-source to connect to the DataFlex database. In this way I get a link to the table and can see changes in DataFlex "RealTime".

I have two posibilities:
1) Use the method described above
2) Get data into Excel (Visual Basic for applications)

If I use the second option I need to connect to a ODBC data source from Excel. Can I use DAO for this?
Avatar billede terry Ekspert
19. juli 2005 - 12:00 #5
Ah!, so it is NOT an Access table/memo field but a field you are linking into Access via a DSN (ODBC) connection!


If you look at the table in design mode (in Access) do you see the field as a memo or just as a text field (255) in length?

The ODBC driver you are using may NOT support all field types!



Have you tried using ADO either in Access or Excel to read data in DataFlex?
Avatar billede nielsbkh Nybegynder
19. juli 2005 - 12:18 #6
If I add a query to a Excel sheet (see below) I get the correct data:

With ActiveSheet.QueryTables.Add(Connection:="ODBC;DRIVER={DataFlex Driver};DBQ=q:\data;SERVER=NotTheServer", Destination:=Range("A1"))
        .CommandText = Array("SELECT ORDRSAG.SAG, ORDRSAG.TEKST" & Chr(13) & "" & Chr(10) & "FROM ORDRSAG ORDRSAG" & Chr(13) & "" & Chr(10) & "WHERE (ORDRSAG.SAG<1000)")
        .Name = "Forespørgsel fra Innoflex"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = True
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .Refresh BackgroundQuery:=False
    End With

From here I can move data into a new Access table with a memo field - it works!

When data changes in DataFlex I need to update my query in Excel, then delete old data in Access, then move updated data from Excel to Access.

This is not the way I want it to work!

Since it is the same data source I'm using, I beleeve it should be posible to get data directly into Access. 

It is still a posibility for me, to get data by ADO or DAO in Excel, but I can not work out how to set up the connection to the data source.
Avatar billede nielsbkh Nybegynder
19. juli 2005 - 12:30 #7
By the way!

The datatype of the field in the connected table is "Notat".

If I use DAO from Excel to insert a long text into the connected table it works. I can insert more than 500 characters and see them from DataFlex. But not the other way around.

It is the same driver and data source I use to read from Excel and from Access.
Avatar billede nielsbkh Nybegynder
19. juli 2005 - 14:53 #8
Jeg har besluttet at benytte nedenstående, som returnerer hele indholdet af feltet tekst. Koden virker både i Excel og Access. Spørgsmål lukkes.

Sub test_conn()

Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset

Set Conn = New ADODB.Connection
Set rs = New ADODB.Recordset

Conn.ConnectionString = "data source = 'Innoflex'"
Conn.Open

rs.Open "select tekst from ordrsag where sag = 854", Conn

MsgBox rs!tekst

Conn.Close
Set Conn = Nothing

End Sub
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester



IT-JOB

A/S Bryggeriet Vestfyen

IT-Architect /Administrator

Udviklings- og Forenklingsstyrelsen

Udbudsjurist til Danmarks største IT-udbud

Udviklings- og Forenklingsstyrelsen

Testmanager til Partsrepræsentation

Cognizant Technology Solutions Denmark ApS

Test Architect - Projects

Politiets Efterretningstjeneste

Centerchef til Center for Support og Proces i PET