Groups | Blog | Home
all groups > vb.net data > january 2005 >

vb.net data : Cannot update the cursor blah, since it is read-only


SQLScott
1/13/2005 8:55:01 AM
I have a VB.Net web service that access a foxpro database. The web service
and the foxpro db are on the same box.

One of the methods in that web service tries to update a column in one of
the foxpro tables, but I get the error:

Cannot update the cursor User, since it is read-only

The read-only attributes on the User.dbf file are not set so I am at a loss
as to why i would get this.

My code looks like this:

conn = "Provider=VFPOLEDB;Data
Source=Data.dbc;SourceType=DBC;UID=;PWD=;Exclusive=No"

cVFPConn = New OleDbConnection(conn)
cVFPConn.Open()

Dim cmd As OleDbCommand
cmd = New OleDbCommand
cmd.Connection = cVFPConn

lNextPOReqNum = lNextPOReqNum + 1
tSQL2 = "UPDATE User SET iporqnxtno = " & lNextPOReqNum
cmd.CommandText = tSQL2
cmd.ExecuteNonQuery()

Is my code not talking correct "VFP"?

btw...i also posted this question on the VFP group just in case, so forgive
the double post...

--
Thanks,

Cindy Winegarden
1/14/2005 5:19:34 PM
Hi SQLScott,

Besides using concatenation to create the SQL string you can use a
parameterized query.

Your SQL essentially looks like "UPDATE User SET iporqnxtno = 2" How does
the FoxPro data engine know which record to update? Usually an Update
statement has a Where clause. If so your SQL would look like "UPDATE User
SET iporqnxtno = 2 Where nPrimaryKey = nSomeValue".

Also, this looks like the typical "take a number, increment, and put it
back" method of generating unique key values that is commonly used in VFP
(and other places). However, without some way to lock other users out of the
record while you get your number and then do the update then you can't be
sure your PO numbers will be unique.

Finally, does the web service account have write permissions to the
directory where the data resides?

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com


[quoted text, click to view]

AddThis Social Bookmark Button