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
ADO and MySql
- lucasdebeltran
- Posts: 1303
- Joined: Tue Jul 21, 2009 8:12 am
- Contact:
Re: ADO and MySql
Hello,
Please, see TDataRow class explained in whatsnew.txt.
Very good class.
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.
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.
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: ADO and MySql
Colin
Nothing specifically wrong with your addnew() and Update() .. please check how you create your Recordset and I suggest using these parameters :
The above code assumes that you have a Primary key that is auto created... xConnect is your connection string to MySql.
Rick Lipkin
Nothing specifically wrong with your addnew() and Update() .. please check how you create your Recordset and I suggest using these parameters :
Code: Select all
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()
Rick Lipkin
-
- Posts: 310
- Joined: Mon Oct 10, 2005 5:10 am
Re: ADO and MySql
Thanks Rick - much appreciated.
Colin
Colin