Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG in Currsoradapter with zero-length/null memo fields
Message
De
16/05/2003 00:58:50
 
 
À
15/05/2003 20:20:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00788822
Message ID:
00789097
Vues:
37
Hi Dennis,

Thank you very much for good repro steps.
It looks like the same issue with empty character fields. Apparently Jet OLEDB provider fails when VFP tries to create zero length input parameter for ADODB.Command object. However, the same operation succeeds for SQL Server OLEDB provider. For example the code below works fine:
CLOSE DATABASES all
clear
LOCAL oCon as ADODB.Connection, oRS as ADODB.Recordset, oCA as CursorAdapter 
oCon=CREATEOBJECT("ADODB.Connection")
oCon.Open("Provider=SQLOLEDB;Data Source=(local);Trusted_Connection=YES")

oCon.Execute("create table #test (f1 int, f2 varchar(10),f3 text)")
oCon.Execute("insert into #test values(1,'11111','111111111111111111111111')")

oRs=CREATEOBJECT("ADODB.Recordset")
oRs.ActiveConnection=oCon

oCom=CREATEOBJECT("ADODB.Command")
oCom.ActiveConnection=oCon

oCA=CREATEOBJECT("CursorAdapter")

oCA.DataSourceType="ADO"
oCA.DataSource=oRs
oCA.UpdateCmdDataSourceType="ADO"
oCA.UpdateCmdDataSource=oCom
oCA.Tables="#test"
oCA.KeyFieldList="f1"
oCA.UpdatableFieldList="f2,f3"
oCA.UpdateNameList="f1 #test.f1, f2 #test.f2, f3 #test.f3"
oCA.SelectCmd="Select * from #test"
oCA.BufferModeOverride= 5
oCA.CompareMemo= .F.

?oCA.CursorFill()
SELECT (oCA.Alias)
LIST

GO top
REplace f2 WITH '', f3 WITH ''
if(!TABLEUPDATE(.T.))
	AERROR(aerrors)
	DISPLAY MEMORY LIKE aerrors
ENDIF
USE 

?oCA.CursorFill()
SELECT (oCA.Alias)
LIST

return
We will address this issue in the next VFP release. In the mean time, you may use a CursorAdapter.BeforeUpdate event as a workaround:
	FUNCTION BeforeUpdate (cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd)
		*?cUpdateInsertCmd
		LOCAL cAlias
		cAlias=ALIAS()
		SELECT (this.Alias)
		if(LEN(ProdDescription)=0)
			cUpdateInsertCmd=STRTRAN(cUpdateInsertCmd,"?"+this.Alias+".ProdDescription","''",1,1,1)
			*?cUpdateInsertCmd
		ENDIF 
		SELECT (cAlias)
	ENDFUNC 
It is possible to write generic code to handle all empty character and memo fields.

You can use similar approach for other issues.
In worst case, you can always call ADODB.Command object directly in BeforeUpdate event and then set cUpdateInsertCmd to empty string (this tells CursorAdapter to do nothing for the record).

Thanks,
Aleksey.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform