Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Foxpro OLE DB Driver - Does it support updating???
Message
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00617493
Message ID:
00617519
Views:
45
Below is an example on how I updated data via the OLE-DB provider.
	' Connect to our VFP database
	set oConnection = Server.CreateObject( "adodb.connection" ) 
	oConnection.Provider = "vfpoledb.1"
	oConnection.ConnectionString = "data source=c:\glgdw_web\data\tastrade.dbc"
	oConnection.Open 
	
	' Update record indicated in txtCustID.
	dim cSQL
	cSQL = "update customer " &_
		   "set "	&_
			"company_name = '" & Request.Form( "txtCustName" ) "', " &_
			"contact_name = '" & Request.Form( "txtCustContact" ) & "' "&_
		   "where " &_
			"customer_id = '" & Request.Form( "txtCustID" ) & "'" 
	
	oConnection.Errors.Clear	
	oConnection.Execute cSQL
		
	' Close everything 
	oConnection.Close
	set oConnection = nothing
>I have only played with the OLD-DB provider and I was able to update data. Nevertheless, I've heard that the OLE-DB provider is extremely sensitive. For example, if the value to update is larger than the field size the OLE-DB provider will choke (rather than truncating the value or telling you that the value is too big for the field.)
>
>>Does anyone know if the foxpro OLE DB driver supports updating Foxpro databases?
>>
>>The following code uses ADO to connect and attempt to edit a simple foxpro table.
>>If I use the ODBC connection string, it works. If I use the OLE DB connection string if causes an error something like
>>
>>"object or provider is not capable of performing the required operation"
>>
>>I have also being playing with visual studio .net, and get a similar problem. I can connect and retrieve data happily using the oledbdataadapter object, but updating, inserting or deleting foxpro tables fails every time.
>>
>>the code listing (please change the file paths and table names if you want to try it)
>>
>>
>>&&&here is the ole db connection string
>>constr='Provider=VFPOLEDB.1;Data Source=C:\FXCLIENT\CSDATA\CSDATA.DBC;Mode=Share Deny None;Extended Properties="";User ID="";Password="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE'
>>
>>&&&here is the odbc connection string
>>constr='DSN=testpms;UID=;PWD=;SourceDB=C:\fxclient\CSdata\csdata.dbc;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;'
>>
>>
>>&&here is the odbc connection string
>>
>>
>>
>>con=Createobject("adodb.connection")
>>
>>con.connectionstring=constr
>>con.Open
>>Sqlstr="select client,surname from clients where client='A0001'"
>>rs=Createobject("adodb.recordset")
>>rs.cursortype=2
>>rs.locktype=3
>>rs.Open(Sqlstr,con)
>>
>>If Not rs.Eof
>> Messagebox("record found")
>> rs.Fields("surname").Value="test update"
>> rs.Update
>>Else
>> Messagebox("record not found")
>>Endif
>>rs.close
>>con.Close
>>RELEASE rs
>>RELEASE con
Hector Correa
Previous
Reply
Map
View

Click here to load this message in the networking platform