//function for creting mapdat file in particular location
void CreateMapDataXML(int city,int selectedindx)
{
//declare variable
//string path;
SqlConnection sqlcon = new SqlConnection( System.Configuration.ConfigurationManager.AppSettings ["Con"]);
SqlCommand sqlcmd;
try
{
sqlcon.Open();
sqlcmd = new SqlCommand("proc_bankmarker", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue("@cityid", city);
sqlcmd.Parameters.AddWithValue("@index", selectedindx);
SqlDataAdapter sqladp = new SqlDataAdapter(sqlcmd);
DataSet ds = new DataSet();
ds.Clear();
sqladp.Fill(ds);
//function for genral
if (city >= 0 && selectedindx >= 0)
{
//map server data file from mapdata folder
path = Server.MapPath("..") + @"\MapData\MapData_" + selectedindx + city +".xml";
}
XmlTextWriter writer = new XmlTextWriter(path, System.Text.Encoding.UTF8);
writer.WriteStartDocument();
writer.WriteStartElement("Banks");
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
writer.WriteStartElement("Bank");
writer.WriteAttributeString("Name", ds.Tables[0].Rows[i]["bank_name"].ToString());
writer.WriteAttributeString("Contact", ds.Tables[0].Rows[i]["Contact_No"].ToString());
writer.WriteAttributeString("lat", ds.Tables[0].Rows[i]["lat"].ToString());
writer.WriteAttributeString("lng", ds.Tables[0].Rows[i]["lng"].ToString());
writer.WriteAttributeString("address", ds.Tables[0].Rows[i]["address"].ToString());
writer.WriteAttributeString("BankOrATM", ds.Tables[0].Rows[i]["bankoratm"].ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
-
ShriKrishna Bhardwaj , With ASP.Net, SQL Server, Javascript
1 comment:
Raise a question in my mind, if you don't mind?
Do we need to flush { writer.Flush(); } the writer before we close it by saying writer.Close();
I never knew u r into programmin'
~nsj
Post a Comment