[fdo-users] SDF unable to Insert, Update.
raghulan
neo.exterminator at gmail.com
Sun Oct 14 21:22:03 PDT 2012
Hello ppl,
I am trying to write to a SDF file which has the following structure..
=======================================================
SDF File Structure
=======================================================
SDF file name : test_file.sdf
schema name : test1
feature class under the schema - i just have only one : Parcels
which has the property definition : Auto_increment, Name, Area, Perimeter
Name = String - Length(255) - nullable(true) - readonly(false)
Area = String - Length(255) - nullable(true) - readonly(false)
Perimeter = String - Length(255) - nullable(true) - readonly(false)
========================================================
I am trying various differnt codes to insert some values to the SDF - my app
crashes.
here is my code snippet.
//test sdf file
string file = @"D:\Test\SDF_Export\testc.sdf";
IConnectionManager conmanager = FeatureAccessManager.GetConnectionManager();
using (IConnection con = conmanager.CreateConnection("OSGeo.SDF"))
{
//get connection dict
IConnectionPropertyDictionary conprop =
con.ConnectionInfo.ConnectionProperties;
ed.WriteMessage("\nInside second connection");
conprop.SetProperty("File", file);
conprop.SetProperty("ReadOnly", "FALSE");
con.Open();
OSGeo.FDO.Connections.ConnectionState connstate =
con.ConnectionState;
if (connstate !=
OSGeo.FDO.Connections.ConnectionState.ConnectionState_Open)
{
ed.WriteMessage("\nCannot read SDF File");
}
else
{
ed.WriteMessage("\nSucessfully read SDF!!!! - Ready for
insert");
//creating iinsert command
IInsert insert_cmd =
(IInsert)con.CreateCommand(CommandType.CommandType_Insert) as IInsert;
//set features class to insert data
insert_cmd.SetFeatureClassName("test:Parcels");
PropertyValueCollection pcoll =
insert_cmd.PropertyValues;
//createing values to be inserted
PropertyValue pval1 = new PropertyValue();
pval1.Name = new Identifier("Name");
Expression ex1 = Expression.Parse("'parcelname1'");
PropertyValue pval2 = new PropertyValue();
pval2.Name = new Identifier("Area");
Expression ex2 = Expression.Parse("'area string'");
PropertyValue pval3 = new PropertyValue();
pval3.Name = new Identifier("Perimeter");
Expression ex3 = Expression.Parse("'Perimeter
string'");
pcoll.Add(pval1);
pcoll.Add(pval2);
pcoll.Add(pval3);
pval1.Value = (ValueExpression)ex1;
pval2.Value = (ValueExpression)ex2;
pval3.Value = (ValueExpression)ex2;
IFeatureReader reader = insert_cmd.Execute();
test_file.sdf
<http://osgeo-org.1560.n6.nabble.com/file/n5008574/test_file.sdf>
if (reader.ReadNext())
Debug.Fail("insert really worked on a read-only
volume");
reader.Close();
Debug.Fail("insert worked on a read-only volume");
}
con.close();
}
============================================================
please let me know where I went wrong, I am not able to write the file, file
is gien full permission for everyone user. and I am able to create SDF file
and add feature class.
-----
-Raghulan Gowthaman
Senior civil BIM Consultant
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/SDF-unable-to-Insert-Update-tp5008574.html
Sent from the FDO Users mailing list archive at Nabble.com.
More information about the fdo-users
mailing list