thank you
i use this sample and now i can add sqlite connection but still i cannot add it to map .it say "it say out of index bounds" my code is here:
OSGeo.FDO.IConnectionManager connManager = FeatureAccessManager.GetConnectionManager();
IConnection conn = connManager.CreateConnection("OSGeo.SQLite");
conn.ConnectionInfo.ConnectionProperties.SetProperty("ReadOnly", false.ToString());
string fileName = @"KaisMapData.sqlite";
conn.ConnectionInfo.ConnectionProperties.SetProperty("File", fileName);
ConnectionState connState = conn.Open();
ed.WriteMessage("connect status is " + connState.ToString() + "\n");
MgResourceService rs;
rs = AcMapServiceFactory.GetService(MgServiceType.ResourceService)
as MgResourceService;
MgFeatureService fs;
fs = AcMapServiceFactory.GetService(MgServiceType.FeatureService)
as MgFeatureService;
MgResourceIdentifier fsId = new MgResourceIdentifier(
"Library://gis_osm_buildings_a_free_1.FeatureSource");
// Create the feature source definition with a required
// parameter of File and an optional parameter of ReadOnly
string xmlString;
FeatureSourceType fsType = new FeatureSourceType();
fsType.Provider = "OSGeo.SQLite";
NameValuePairType param = new NameValuePairType();
param.Name = "File";
param.Value = @"C:\Users\OmraniS\Desktop\gis_osm_buildings_a_free_1.sqlite";
NameValuePairType param2 = new NameValuePairType();
param2.Name = "ReadOnly";
param2.Value = "True";
fsType.Parameter = new NameValuePairType[] { param, param2 };
// Serialize the feature source object model to xml string
using (StringWriter writer = new StringWriter())
{
XmlSerializer xs = new XmlSerializer(fsType.GetType());
xs.Serialize(writer, fsType);
xmlString = writer.ToString();
}
// Convert the Unicode string to UTF8 bytes for Resource Service
byte[] unicodeBytes = Encoding.Unicode.GetBytes(xmlString);
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode,
Encoding.UTF8, unicodeBytes);
// Create a byte reader containing the XML feature
// source definition. Store the definition in the repository
MgByteSource xmlSource = new MgByteSource(utf8Bytes,
utf8Bytes.Length);
rs.SetResource(fsId, xmlSource.GetReader(), null);
IDescribeSchema descSchemaCmd = conn.CreateCommand(CommandType.CommandType_DescribeSchema) as IDescribeSchema;
FeatureSchemaCollection fsc = descSchemaCmd.Execute();
FeatureSchema schema = fsc[0];
MessageBox.Show((schema.Classes.IndexOf("@Default")).ToString());
ClassDefinition classDef = schema.Classes[schema.Classes.IndexOf("@Default")];
MessageBox.Show(fsId.ToString());
MessageBox.Show(rs.ToString());
MgLayerBase layer = AcMapLayer.Create(fsId,rs);
layer.SetName("NewLayer");
AcMapMap currentMap = AcMapMap.GetCurrentMap();
currentMap.GetLayers().Add(layer);
}