Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert+Update+Delete problem on Compact SQL Table via CA
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01506814
Message ID:
01506817
Views:
45
>Hi All,
>with below codes i can see the entire records from .SDF file (SQL Compact Edition) well. But i Insert+Update+Delete actions on it :( where is my missing issue ?
>
>TIA
>
>
>* This script handles the ADO Connection and uses a CursorAdapter object
>* to retrieve data to a cursor.
>
>Public oCA As CursorAdapter
>Local oConn      As ADODB.Connection
>Local oRS        As ADODB.Recordset
>Local oComm      As ADODB.Command
>Local oException As Exception
>Local cConnString
>
>* Handle connections - insert connection code
>*-cConnString = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;"+;
>"Data Source=D:\Depomatik.sdf"
>
>
>cConnString = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;"+;
>	"Data Source=D:\SOYKAN\MYSOFTWARE\DEPOMATIK_MOBILE_NET\DepomatikNet\DepomatikNet\bin\Debug\Depomatik.sdf"
>
>
>
>Try
>	oConn  = Createobject('ADODB.Connection')
>
>	* Ensure that you handle userid and password if not
>	* specified in connection string.
>	*   ex. oConn.Open(cConnString, userid, password)
>	oConn.Open(cConnString)
>	oComm = Createobject("ADODB.Command")
>	oComm.ActiveConnection = oConn
>
>
>	oRS = Createobject("ADODB.Recordset")
>	oRS.Datasource.CursorLocation = 3   &&adUseClient
>	oRS.Datasource.LockType = 3   &&adLockOptimistic
>	oRS.ActiveConnection = oConn
>
>	oCA=Createobject("CursorAdapter")
>	oCA.DataSourceType = "ADO"
>	oCA.Datasource     = oRS
>	oCA.MapBinary      = .T.
>	oCA.MapVarchar     = .T.
>	oCA.SendUpdates    = .T.
>	oCA.KeyFieldList   =  "MyGuid"  && Put the Key Field list here
>	oCA.WhereType      =  1 && Key Fields
>
>	oCA.Alias                    = "CARI"
>	oCA.SelectCmd                = "SELECT * FROM CARI"
>	oCA.InsertCmdDataSourceType  = "ADO"
>	oCA.UpdateCmdDataSourceType  = "ADO"
>	oCA.DeleteCmdDataSourceType  = "ADO"
>	oCA.RefreshCmdDataSourceType = "ADO"
>
>	oCA.InsertCmdDataSource      = oComm
>	oCA.UpdateCmdDataSource      = oComm
>	oCA.DeleteCmdDataSource      = oComm
>	oCA.RefreshCmdDataSource     = oComm
>
>
>	If !oCA.CursorFill(.F.,.F.,-1,oComm)
>		* Replace with error code here
>		Local laError
>		Dimension laError[1]
>		Aerror(laError)
>		Messagebox(laError[2])
>	Else
>		* Replace with user code here. Code below allows for
>		* you to edit and send updates to the backend.
>		Local laFlds,lcStr,lnFldCount,i
>		Dimension laFlds[1]
>		lnFldCount=Afields(laFlds)
>		lcStr=""
>		lcStr2 = ""
>		For i = 1 To lnFldCount
>			lcStr  = lcStr  + laFlds[m.i,1] +  ","
>			lcStr2 = lcStr2 + laFlds[m.i,1] +  " CARI."+laFlds[m.i,1]+"," && There should be SPACE before CARI
>		Endfor
>		oCA.UpdatableFieldList = Left(lcStr , Len(lcStr )-1) && To remove last comma
>		oCA.UpdateNameList     = Left(lcStr2, Len(lcStr2)-1) && To remove last comma
>
>		*-BROWSE NORMAL NOWAIT
>	Endif
>
>Catch To oException
>	* Replace with exception handling code here
>	Messagebox(oException.Message)
>Endtry
>
>* Add user code here.
>* Note: cursors created by CursorAdapter object are closed when object is released.
>
>
>oConn.Close()
>
>
>
>here is my unsuccessful codes (especially w/o error but no IUD actions nothing changes on the table)
>
>
>cSQL = [ insert into oCa.Alias(ckodu,cadi) values('XXX','ATA') ]
>
>oComm.Execute(m.cSQL)
>Tableupdate(2,.T.,oCA.Alias)
>oCA.CursorRefresh()
>Browse Normal &&Nowait
>
>cSQL = [ update oCa.Alias set cadi='Dila Hatem' where ckodu='XXX' ]
>oComm.Execute(m.cSQL)
>Tableupdate(2,.T.,oCA.Alias)
>oCA.CursorRefresh()
>Browse Normal &&Nowait
>
>cSQL = [ delete from oCa.Alias where ckodu='XXX' ]
>oComm.Execute(m.cSQL)
>Tableupdate(2,.T.,oCA.Alias)
>oCA.CursorRefresh()
>Browse Normal &&Nowait
>
>
Your SQL statements will not execute as oCA.ALIAS is not known to the SQL CE. Use the actual table names instead,
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform