Click here to Skip to main content
16,001,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a C# console application .where after application run data will store into XML file . how i will insert the same data into SQL db table. i want to insert same data into database . read from xml nodes & insert into columns .

What I have tried:

Server
home rajesh1 /home
serverlist 182.117.197.350 /serverlist
host rajesh host
site DOWN /site
Posted
Updated 4-Oct-16 22:25pm
v3

What you need to do is break your problem down into smaller pieces and then you won't feel so overwhelmed that you don't know where to start.

1) First thing you need to do is figure out how to read XML in c#.

read XML file in c - Google Search[^]

If serialization is an option, review how that works in C#

Google[^]

2) If you did not use serialization, then you need to read the XML and map it to an object of some sort (or you could just write insert queries here).

By this i mean you could have an object of say...Person. Here would be the step that you map the XML elements to the properties of Person and add each Person to a list of type Person.

3) Loop through your list of Person (ex: var persons = new <Person>();) and write insert queries, or use EntityFramework to insert that data into your database.

Entity framework C# - Google Search[^]

Once you get started on this project, should you get stuck, feel free to come back with a clear explanation of your issue and any relevant code samples. We are not a service that does your projects for you. You also need to remember we don't have access to your computer, your hard drive, nor do we read minds or know anything about your project. Vague questions do nothing but get people annoyed that they can't provide you adequate assistance. If you are able to provide a clear explanation and relevant code samples I am sure someone will be happy to help you when you need it.
 
Share this answer
 
you can also take the help of this link to importing data from XML file to SQL Server
Importing and Processing data from XML files into SQL Server tables[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900