|
Hi,
I work on the code generation xml file I do not know how to modify it to populate the xml using a query sqlserver:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Text;
public partial class Etudiant11 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public class Etudiant
{
public int NumInscription { get; set; }
public string Nom { get; set; }
public string Prenom { get; set; }
public string CodeSexe { get; set; }
}
protected void Button1_Click(object sender, EventArgs e)
{
XmlSerializer serializer = new XmlSerializer(typeof(List<Etudiant>));
List<Etudiant> etudiants = new List<Etudiant>();
FileInfo fi = new FileInfo(@"C:\Temp\Etudiants.xml");
Etudiant etudiant = new Etudiant() { NumInscription = 123, Nom = "xxx", Prenom = "", CodeSexe = "M" };
etudiants.Add(etudiant);
etudiants.Add(etudiant);
etudiants.Add(etudiant);
using (MemoryStream mem = new MemoryStream())
{
serializer.Serialize(mem, etudiants);
using (FileStream fs = new FileStream(fi.FullName, FileMode.Create))
{
using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
{
sw.Write(Encoding.UTF8.GetString(mem.ToArray()));
}
}
}
etudiant = null;
etudiants = null;
using (FileStream stream = fi.OpenRead())
{
XmlReader reader = XmlReader.Create(stream);
string str = reader.ReadInnerXml();
if (serializer.CanDeserialize(reader))
{
etudiants = (List<Etudiant>)serializer.Deserialize(reader);
}
}
foreach (Etudiant ee in etudiants)
{
Response .Write (string.Format("UPDATE ETUDIANT SET ETUDIANT_NOM = '{0}', ETUDIANT_PRENOM = '{1}', CODE SEXE = '{2}' WHERE NUM_INSCRIPTION = {3}", ee.Nom, ee.Prenom, ee.CodeSexe, ee.NumInscription));
}
}
} thanks
|
|
|
|
|
Do you mean you want to save an Etudiant to the DB or you want to populate an Etudiant from the DB?
|
|
|
|
|
You are trying to use an update statement on a geenric list of ETUDIANT objects. AFAIK, you cannot do this. Since your aim is to modify the XML file, you can make use of XmlDocument class.
|
|
|
|
|
Hi,
I try to create an xml file (from the database ) containing the student of a module, and then allow the teachers to download the file and convert it to Excel and insert markes for students then send the data to bda.
I do not know how do this, and if my way is right or not, I need your advice and help.
Thanks
|
|
|
|
|
Why are you creating XML?
Just create an Excel file from the database and let user download it. Once user is done with the changes, have a place where he can upload it and then save it back to the database.
You also get rid of this download and upload. Have a page with some GridView to display the student's records and have a set of controls where one can edit the data. Place a save button and make changes directly to the database instead of having files in between.
|
|
|
|
|
Hi,
I already tried the method of the gridview but I have hundreds of students in a module managing the grid is heavy.
To excel I try this code
cn.Open();
SqlDataAdapter da = new SqlDataAdapter(@"DECLARE @MATIERE nvarchar(max)
SELECT @MATIERE =
STUFF(
(
select distinct ',[' + LIBELLE_MATIERE + ']'
from MATIERE where CODE_MODULE =11
for xml path('')
),
1,1,'')
DECLARE @SQL nvarchar(max)
SELECT @SQL = N'
select
*
from (
SELECT ETUDIANT.NUM_INSCRIPTION, ETUDIANT.NOM_PRENOM_ETUDIANT_ARABE,EXAMEN.CODE,
EXAMEN.NOTE,
MATIERE.LIBELLE_MATIERE
FROM ETUDIANT INNER JOIN
EXAMEN ON ETUDIANT.NUM_INSCRIPTION = EXAMEN.NUM_INSCRIPTION INNER JOIN
CAPITALISE_MODULE ON
ETUDIANT.NUM_INSCRIPTION = CAPITALISE_MODULE.NUM_INSCRIPTION INNER JOIN
MATIERE ON EXAMEN.CODE_MATIERE = MATIERE.CODE_MATIERE INNER JOIN
MODULE ON CAPITALISE_MODULE.CODE_MODULE = MODULE.CODE_MODULE
AND MATIERE.CODE_MODULE = MODULE.CODE_MODULE
WHERE (CAPITALISE_MODULE.CODE_MODULE = 11) AND
(CAPITALISE_MODULE.CODE_TYPE_RELATION_MODULE = 1)
) Data
PIVOT (
SUM(NOTE)
FOR LIBELLE_MATIERE
IN (
' + @MATIERE + '
)
) PivotTable
'
exec sp_executesql @SQL
", cn);
DataTable dt = new DataTable();
da.Fill(dt);
cn.Close();
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
string sep = "";
foreach (DataColumn dc in dt.Columns)
{
Response.Write(sep + dc.ColumnName);
sep = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dt.Rows)
{
sep = "";
for (i = 0; i < dt.Columns.Count; i++)
{
Response.Write(sep + dr[i].ToString());
sep = "\t";
}
Response.Write("\n");
}
}
}
excel file generated by this code gives me this:
Sudeni_id_____marks_matter1____marks_matte2
but how to allow just the marks between 0 and 20?
is a method to calculate the average module directl:ysum(marks_matter1*coefficient)/sum(coefficent)
I chose XML because it's easy to send to the database(I read that in an article )but i have a problem with generate it with sql,excel i dont have any edea if the data are not the same table.
Thanks
|
|
|
|
|
hy,
i have a requirement in which all the files present in the gadagrid has to be printed contiously without having to set the printer option again and agin...
i have used the following code in code behind
HtmlControl htmctl = (HtmlControl)this.FindControl("myFrame");
htmctl.Attributes["src"] = "../Files/11012009to021520101.txt";
and in java script
iframe.focus();
iframe.print();
I am unable to set default printer settings so that the printer dialog will not come out every time
Thanks & Regards,
Raghvendra Panda
modified on Wednesday, June 2, 2010 7:58 AM
|
|
|
|
|
but that shouldn't be down to you, it should be down to the end user. Someone might not want to print it to a default printer, they might want to send it do a pdf creator and email it on. It's a server trying to mess with client side functions silently and as such is unlikely to be allowed.AFAIK, javascript print commands will always do it too.
It's something akin to fax abuse where your code could automatically print out an ad when the user visits the page. I suggest you throw back this requirement because of these concerns.
|
|
|
|
|
Thanks For The Reply.But Thats What The requirement is..Soon As he clicks on print,all the files in the printer should get printed one by one.and the printer dialog should not come out again and again for every file.
|
|
|
|
|
Ok, you've cleared up the original problem a bit.
Can you not concatenate the files together for printing? There's no real way to do this from your app, it's seperate files so they'll each generate a dialog anyway.
|
|
|
|
|
Hi Guys,
I have no idea on developing Hosting Appliction like Godaddy.com.
Plz guide me if any one knows .with proper References adn sample code
Thanks
Srinivas
Dot net Programmer
|
|
|
|
|
|
I think he meant "How can I make a GoDaddy clone".
lol, easy...should only take about 30 minutes. Jeez.
Surely there is some good GoDaddy sample code out there.
|
|
|
|
|
hi, everybody..
I want to retrieve client drives (in short file manager).
Actually i am trying with Directory.GetLogicalDrive() function, but its returns logical drive of the server in which asp.net website is installed. i want logical drives from client PC..
i.e. i want to client to be select some files or folder from own PC and by that path i upload whole folder or files without using fileupload control limitations.
im using this code right now
foreach (string drive in Directory.GetLogicalDrives())
{
TreeNode tn = new TreeNode();
tn.Text = drive;
tn.Value = drive;
TreeView1.Nodes.Add(tn);
}
thanks in advance...
please i m really stuck at this.
Best Regards,
Punit Belani
|
|
|
|
|
punit belani wrote: i.e. i want to client to be select some files or folder from own PC
You have to use any Scripting language to do so. Use Javascript to get the files on the client system and then bind it to tree or any control you want to show the result.
|
|
|
|
|
first of all thanks for reply.
i am new to scripting language, can you give some broader idea, for using java scripts for this purpose. or give some useful links.
|
|
|
|
|
|
thanks for reply, im now start working on it.
|
|
|
|
|
Hi,
I have two sites and I want to login from one to another. I have simply used Response.Redirect("http://www.site1.com?username=abc&password=123").
I have encrypted username and password for security.
I want only to confirm is this approach good or not?
Thanks
|
|
|
|
|
Dot-Net-Dev wrote: I want only to confirm is this approach good or not?
No, not at all!
Dot-Net-Dev wrote: I have encrypted username and password for security.
Username/password or any sensitive information should never be passed in querystring even if encrypted!
|
|
|
|
|
|
Set an authentication cookie. There's more than a few examples out there but here's a starting point for what I think you want:
http://msdn.microsoft.com/en-us/library/9wff0kyh.aspx
Never ever use querystrings for this sort of thing. You're exposing an entry point, encrypted or no, for someone savvy enough to mess with.
|
|
|
|
|
yes, @Sandeep Mewara is true. there are many ways for decrypt your encryption. never use sensitive data in querystring.
|
|
|
|
|
Hi
How can I use word press blog and forum in my asp.net web application
as I have less time and already we have blog and forum in word press so any way to do above.
thanks
You get the best out of others when you give the best of yourself.
|
|
|
|
|
Word press is written in PHP, I don't think you'll be able to easily integrate it into your asp.net app. There are plenty of other blogs you could use that are implemented in asp.net.
|
|
|
|