ADO and MySql

ADO and MySql

Postby Colin Haig » Tue Jul 09, 2013 9:18 am

Hi All

I a trying to use MySQL and ADO - I have a connection to the database and can open a table
but not sure what code to use to add records - according to a wiki page I found called ado-related stuff I can do the following

oRs:AddNew()
oRs:Fields('code'):Value := 'Test')
oRs:Update()

That code does not produce any errors but the record is not added

the other way is to use a insert statement which I have got to work.

Is it worth using AdoRDD ( not sure if it works with xHarbour or where I get it from )

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: ADO and MySql

Postby lucasdebeltran » Tue Jul 09, 2013 10:01 am

Hello,

Please, see TDataRow class explained in whatsnew.txt.

Very good class.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO and MySql

Postby Rick Lipkin » Tue Jul 09, 2013 12:56 pm

Colin

Nothing specifically wrong with your addnew() and Update() .. please check how you create your Recordset and I suggest using these parameters :

Code: Select all  Expand view

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType     := 1        // opendkeyset
oRs:CursorLocation := 3        // local cache
oRs:LockType       := 3        // lockoportunistic

cSql := "Select * From [YourTable] "

TRY
   oRs:Open( cSQL,xCONNECT )
CATCH oErr
   MsgInfo( "Error in Opening YOURTABLE table" )
   RETURN(.F.)
END TRY

oRs:AddNew()
oRs:Fields("YourField"):Value := "Test"
oRs:Update()

xBrowse( oRs )

oRs:CLose()
 


The above code assumes that you have a Primary key that is auto created... xConnect is your connection string to MySql.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: ADO and MySql

Postby Colin Haig » Tue Jul 09, 2013 11:45 pm

Thanks Rick - much appreciated.

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 97 guests