FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TXT to SQL
Posts: 18
Joined: Wed Nov 04, 2009 09:41 AM
TXT to SQL
Posted: Thu Dec 31, 2009 11:53 AM

Hi all,

I'm implementing a method to pass information from a file. Txt to a SQL database. The Txt file is comprised of eight fields / columns (Code, Name, Country ...) that pressing a button on my application I want to be dumped in SQL. The connection is done via ADO.

This would be the method that I try to use:

method TXTtoSQL() class TFormPrincipal

LOCAL o
LOCAL oRs
LOCAL a
LOCAL adUseClient
LOCAL adOpenStatic

//Open conexion.
WITH OBJECT o := TAdoDatasource():Create()
:cConnect := "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=prueba;Data Source=Servidor"
:Connect()
END

//Recordset.
WITH OBJECT oRs := TSqlQuery():Create(o)
Datasource := o
:ncursorlocation := adUseClient
:ncursortype := adOpenStatic
:cSelect := "SELECT * FROM dbo.clientes"
END
oRs:Open()

//Verify that the connection is open.
IF !oRs:lOpen
MsgInfo("Conexion error")
ENDIF

//insertions in the SQL DB.
::cFicheroR := Memoread("Info.txt")
FOR ::nLine := 1 TO INT(LEN(::cFicheroR) / 554 ) STEP 1

::cLine := SUBSTR(::cFicheroR, (::nLine -1) *554, 554)
::cLine = StrTran(::cLine, Chr(10), "") //Delete Tab.

Append Blank
REPLACE cCodCli with SUBSTR(::cLine,1,6)
REPLACE cNomCli with SUBSTR(::cLine,7,100)
REPLACE cNomCom with SUBSTR(::cLine,107,100)
REPLACE cDirCli with SUBSTR(::cLine,207,100)
REPLACE cPobCli with SUBSTR(::cLine,307,100)
REPLACE cCodProv with SUBSTR(::cLine,407,4)
REPLACE cPTLCli with SUBSTR(::cLine,411,10)
REPLACE cFaxCli with SUBSTR(::cLine,421,10)
REPLACE cDniCif with SUBSTR(::cLine,438,10)
REPLACE cContacto with SUBSTR(::cLine,453,10)

NEXT

MsgInfo(Str(oRs:autoin))

return nil

Pressing the button to import TXT to SQL I get this error:

Application

Path and name: C:\Trabajos\Trab\Pruebas\Source\prueba1.exe (32 bits)
Size: 1,518,080 bytes
Time from start: 0 hours 0 mins 4 secs
Error occurred at: 12/31/09, 12:00:27
Error description: Error ADODB.Recordset/16389 E_FAIL: PROPERTIES
Args:
[ 1] = C Update Resync

Stack Calls

Called from: win32ole.prg => TOLEAUTO:PROPERTIES(0)
Called from: xSqlQuery.prg => (b)XSQLQUERY:XSQLQUERY(74)
Called from: => TSQLQUERY:RECORDSETCHGRESYNCTYPE(0)
Called from: xSqlQuery.prg => TSQLQUERY:OPEN(302)
Called from: prueba1.prg => TFORMPRINCIPAL:TXTTOSQL(256)
Called from: prueba1.prg => (b)TFORMPRINCIPAL:NEW(109)
Called from: BUTTON.PRG => TBUTTON:CLICK(0)
Called from: CONTROL.PRG => TBUTTON:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => SENDMESSAGE(0)
Called from: DIALOG.PRG => TDIALOG:COMMAND(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: DIALOG.PRG => TDIALOG:HANDLEEVENT(0)
Called from: => DIALOGBOX(0)
Called from: DIALOG.PRG => TDIALOG:ACTIVATE(0)
Called from: prueba1.prg => TFORMPRINCIPAL:SHOW(131)
Called from: prueba1.prg => MAIN(16)

Any idea to solve it ...

Thanks in advance.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TXT to SQL
Posted: Thu Dec 31, 2009 02:36 PM

Diego,

It seems as somewhere in your code you are using oRs:Properties and such data is not available

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion