Add the XSD to the project, change it's build type to Embedded Resource. You'll use the Namespace to get at it. For example, if your assembly default namespace is MyDataAccess, the resource base name will be MyDataAccess.MySchemaFile.xsd. You'd use Assembly.GetExecutingAssembly().GetManifestResourceStream to load it. Unfortunately, SqlXmlCommand only accepts paths to the SchemaPath So, you embed the XSD, then write it out as a temporary file, use it, and delete the temporary file:
// excuse the C#
string tmpFilePath = Path.GetTempFileName();
try
{
TextReader rdr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyDataAccess.MySchemaFile.xsd");
TextWriter wr = new StreamWriter(tmpFilePath, false);
wr.WriteLine(rdr.ReadToEnd());
wr.Close();
rdr.Close();
// now tmpFilePath can be used in your SqlXmlCommand.SchemaPath until done, e.g.,
// cmd.SchemaPath = tmpFilePath;
}
catch (Exception e)
{
// handle the exception
}
finally
{
// get rid of that temp file!
if (File.Exists(tmpFilePath)) File.Delete(tmpFilePath);
}
Ian Mariano - http://www.ian-space.com/
"We are all wave equations in the information matrix of the universe" - me