Cannot update: Read-only

  • Thread starter Thread starter John Spiegel
  • Start date Start date
J

John Spiegel

Hi,

This is probably simple, but I've got a very simple C# function that
connects to a VFP database and takes a SQL command as a parameter. When I
attempt to send that command to the database (ExecuteNonQuery), it throws an
exception indicating "Cannot update the cursor <TableName>, since it is
read-only."

Windows shows it as writable and there's nothing within the database itself
to set the table as read-only.

Any ideas on where to set it to allow for writable access to the table?

TIA,

John
 
John,

Can you post a little code - including your declarations of the connection
(remove the username/password if you post the connection string), the
command including the TSQL, and the call to ExecuteNonQuery.

Kathleen
 
Hi Kathleen,

Thanks for responding. The code follows later. I'm calling it with the
following SQL command (this is VFP, not TSQL) as a parameter:

UPDATE tFormData SET ClientFK = 1 WHERE ClientFK < 0

The command _is_ valid VFP-SQL syntax.

I've done very little data access via OLE DB/ODBC. Is there a piece that
can be included in the connection string that flags read-only v. write
behavior?

Code:

public string DatabaseSQL (string SQLCommand)
{
string cReturn = "";

// Connectionstring pulled from config file:
// "Provider=vfpoledb.1;Data
Source=c:\inetpub\wwwroot\BasicService\Data\System.dbc"
OleDbConnection DataConnection =
new
OleDbConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
OleDbCommand SQLFunction =
new OleDbCommand( SQLCommand, DataConnection );
try
{
DataConnection.Open();
SQLFunction.ExecuteNonQuery();
DataConnection.Close();
}
catch( OleDbException e )
{
cReturn = e.Message;
}
catch( Exception e )
{
cReturn = e.Message;
}
finally
{
if (Convert.ToString( DataConnection.State ) == "Open")
DataConnection.Close();
}
return cReturn;
}


Thanks!

- John
 
John,

I looked through this and do not see any problems. The only thing I can
think of is that there is a permissions problem on the directory or file,
but you said you've checked that. Sorry I can't be of more help.

--
Kathleen Dollard
Microsoft MVP
Author "Code Generation in Microsoft .NET"


John Spiegel said:
Hi Kathleen,

Thanks for responding. The code follows later. I'm calling it with the
following SQL command (this is VFP, not TSQL) as a parameter:

UPDATE tFormData SET ClientFK = 1 WHERE ClientFK < 0

The command _is_ valid VFP-SQL syntax.

I've done very little data access via OLE DB/ODBC. Is there a piece that
can be included in the connection string that flags read-only v. write
behavior?

Code:

public string DatabaseSQL (string SQLCommand)
{
string cReturn = "";

// Connectionstring pulled from config file:
// "Provider=vfpoledb.1;Data
Source=c:\inetpub\wwwroot\BasicService\Data\System.dbc"
OleDbConnection DataConnection =
new
OleDbConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
OleDbCommand SQLFunction =
new OleDbCommand( SQLCommand, DataConnection );
try
{
DataConnection.Open();
SQLFunction.ExecuteNonQuery();
DataConnection.Close();
}
catch( OleDbException e )
{
cReturn = e.Message;
}
catch( Exception e )
{
cReturn = e.Message;
}
finally
{
if (Convert.ToString( DataConnection.State ) == "Open")
DataConnection.Close();
}
return cReturn;
}


Thanks!

- John


Kathleen Dollard said:
John,

Can you post a little code - including your declarations of the connection
(remove the username/password if you post the connection string), the
command including the TSQL, and the call to ExecuteNonQuery.

Kathleen
When
 
Thanks, Kathleen. While not yet 100% sure, it is looking a lot like an
issue in IIS. When I tried moving the files out from under the
inetpub/wwwroot folder it couldn't even find the files. However, running
the same code from Web Matrix worked perfectly. Looks like I'm going to
have to learn more about the differences in how WM hosts a page!

- John

Kathleen Dollard said:
John,

I looked through this and do not see any problems. The only thing I can
think of is that there is a permissions problem on the directory or file,
but you said you've checked that. Sorry I can't be of more help.

--
Kathleen Dollard
Microsoft MVP
Author "Code Generation in Microsoft .NET"


John Spiegel said:
Hi Kathleen,

Thanks for responding. The code follows later. I'm calling it with the
following SQL command (this is VFP, not TSQL) as a parameter:

UPDATE tFormData SET ClientFK = 1 WHERE ClientFK < 0

The command _is_ valid VFP-SQL syntax.

I've done very little data access via OLE DB/ODBC. Is there a piece that
can be included in the connection string that flags read-only v. write
behavior?

Code:

public string DatabaseSQL (string SQLCommand)
{
string cReturn = "";

// Connectionstring pulled from config file:
// "Provider=vfpoledb.1;Data
Source=c:\inetpub\wwwroot\BasicService\Data\System.dbc"
OleDbConnection DataConnection =
new
OleDbConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
OleDbCommand SQLFunction =
new OleDbCommand( SQLCommand, DataConnection );
try
{
DataConnection.Open();
SQLFunction.ExecuteNonQuery();
DataConnection.Close();
}
catch( OleDbException e )
{
cReturn = e.Message;
}
catch( Exception e )
{
cReturn = e.Message;
}
finally
{
if (Convert.ToString( DataConnection.State ) == "Open")
DataConnection.Close();
}
return cReturn;
}


Thanks!

- John


Kathleen Dollard said:
John,

Can you post a little code - including your declarations of the connection
(remove the username/password if you post the connection string), the
command including the TSQL, and the call to ExecuteNonQuery.

Kathleen

Hi,

This is probably simple, but I've got a very simple C# function that
connects to a VFP database and takes a SQL command as a parameter.
When
I
attempt to send that command to the database (ExecuteNonQuery), it throws
an
exception indicating "Cannot update the cursor <TableName>, since it is
read-only."

Windows shows it as writable and there's nothing within the database
itself
to set the table as read-only.

Any ideas on where to set it to allow for writable access to the table?

TIA,

John
 
¤ Thanks, Kathleen. While not yet 100% sure, it is looking a lot like an
¤ issue in IIS. When I tried moving the files out from under the
¤ inetpub/wwwroot folder it couldn't even find the files. However, running
¤ the same code from Web Matrix worked perfectly. Looks like I'm going to
¤ have to learn more about the differences in how WM hosts a page!

Since this appears to be a web application, did you provide write access to the folder for the
ASPNET account?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Hi Paul,

Thanks for jumping in! I hadn't explicitly done so, but have gone in and
tried about every combination I can find of assigning write access to that
account as well as on folders and virtual folders but still no luck.

- John


 
¤ Hi Paul,
¤
¤ Thanks for jumping in! I hadn't explicitly done so, but have gone in and
¤ tried about every combination I can find of assigning write access to that
¤ account as well as on folders and virtual folders but still no luck.
¤
¤ - John
¤

Not sure about FoxPro, but with an Access database you need Create, Read, Update and Write access.
Have you provided these permissions for the folder to the ASPNET account?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Hi Paul,

I'll doublecheck those settings, thanks. I can't be 100% sure, but I'm
beginning to wonder if the problem is in the OLE DB driver for VFP itself.
I replaced the connection with an Access database and it worked just fine.
Also, while not the same errors specifically, I've found some KB article
indicating some fairly serious flaws in that provider as well. May have to
shelve this one for a while.

Thanks again,

John
 
Back
Top