create XML from database table
hi,
I am trying to create a XML file from a SQL Server database table. But it is showing an error. My code is :
using (StreamWriter sw = File.CreateText(path))
{
string source = ConfigurationSettings.AppSettings["dbString"];
SqlConnection con = new SqlConnection(source);
SqlXmlCommand cmd = new SqlXmlCommand(source);
cmd.CommandText = "select * from node_master";
cmd.RootTag = "TREENODES";
cmd.CommandType = SqlXmlCommandType.Sql;
DataSet ds = new DataSet();
SqlXmlAdapter xa = new SqlXmlAdapter(cmd);
xa.Fill(ds);
ds.WriteXml(sw, XmlWriteMode.IgnoreSchema);
}
But it is showing an "System error" in the Red line.
Error is:
Exception Details: Microsoft.Data.SqlXml.ConnectionStringNotSetExcept ion: System error.
How can I solve this problem?
Angshujit
__________________
Angshujit
|