I would like to see if anyone can guide me on my first project.
This is to obtain a set of records from a SQL database and put them in Datagridview.
Charted records put them in the datagridview by a list, now I would like to pass these values to a xml.
This is my code that I have so far
private void BtnView_Click (object sender, EventArgs e) { { List accountlist = new List (); string sql = "[Catalogocuentas]"; OConnection SqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ContabilidadElectronicaConnection"].ConnectionString); Ocmd SqlCommand = new SqlCommand (sql, oConnection); oCmd.CommandType = CommandType.StoredProcedure; try { oConnection.Open (); using (SqlDataReader dr = oCmd.ExecuteReader (CommandBehavior.CloseConnection)) { while (dr.Read ()) { Accounts p = new Accounts (); p.AcctCode = dr ["AcctCode"] ToString ().; p.AcctName = dr ["AcctName"] ToString ().; p.U_CODAGRU = dr ["U_CODAGRU"] ToString ().; p.U_natu = dr ["U_natu"] ToString ().; accountlist.Add (p);
}
}
}
catch (Exception ex)
{
MessageBox.Show ("Error \ n \ nDescription Tecnica occurred: \ n" + ex.ToString (), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dataGridView1.DataSource = accountlist;
}
}
private void Btncuentas_Click (object sender, EventArgs e)
{
XmlElements = new XElement XElement ("Accounts" Cuentas.Select (i => new XElement ("accountlist", i)));
System.Console.Write (xmlElements);
System.Console.Read ();
No comments:
Post a Comment