[VNET 1.0] Error wirth VCursor.Add + Update Methods
Ivan Smahin
ivan_smahin at valentina-db.com
Fri Mar 10 02:00:26 CST 2006
Hello SoftIl,
Friday, March 10, 2006, 1:34:12 AM, you wrote:
> Hi Ruslan,
> if I run the following code (code is from your VNET-Excample
> "Sample3") I get an exception "Can't be updated" if I call c.Add().
> I get the same exception if I call c.Update() for existing records.
> try
> {
> Valentina.Init(6 * 1024 * 1024, String.Empty);
> using(VDatabase db = new VDatabase())
> {
> db.Create("Sample3");
> VBaseObject t = db.CreateTable("T1");
> t.CreateField("ID", FieldType.kLong);
> t.CreateField("BLOB", FieldType.kBLOB, 1024);
> Byte [] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
> using(VCursor c = db.SqlSelect("SELECT ID, BLOB FROM T1 WHERE RecID=0"))
> {
> for(int i = 0; i < 100; i++)
> {
> c.SetBlank();
> c[1] = i;
> (c[2] as VBLOB).WriteBLOBData(data);
> c.Add();
> }
> }
> }
> Console.Read();
> Valentina.Shutdown();
> }
> catch(Exception ex)
> {
> Console.WriteLine(ex.Message);
> }
You use read-only cursor. It is impossible to use such a cursor for
modifying data.
You should something like this:
using(VCursor c = db.SqlSelect("SELECT ID, BLOB FROM T1 WHERE
RecID=0", EVCursorLocation.kServerSide, EVLockType.kReadWrite ))
--
Best regards,
Ivan mailto:ivan_smahin ÎÁ valentina-db.com
More information about the Valentina
mailing list