By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,990 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,990 IT Pros & Developers. It's quick & easy.

How to save file (.xml) to Sql Server database using Javascript?

P: 40
Is there any way to create xml file and save it in SQL Server database all using javascript? I have no security issues for the purpose i need to do it. Though if anyone could give me some better idea with some sample code, that will be appreciated....

I am generating xml stuff to be saved to database using javascript, but now I am wondering how to save it. Or should i use webservice for this?
Actually I want to achieve above mentioned task in very a efficient and light weighted application manner.......
Aug 14 '09 #1
Share this Question
Share on Google+
7 Replies


Dormilich
Expert Mod 5K+
P: 8,639
@saadkhan
though you can create an XML file itís not possible to save it to DB with Javascript alone (simple reason is, because JS runs only on the client and the DB is on the server)
Aug 14 '09 #2

Dheeraj Joshi
Expert 100+
P: 1,123
You cannot store the XML file (for that matter anything ) into database through java script.

This is the main disadvantage of JS.(Because it is only for client side and client side do not directly interacts with data base engine.)
Aug 15 '09 #3

gits
Expert Mod 5K+
P: 5,320
'disadvantage' is a bit too harsh ... JavaScript doesn't have the purpose to interact with a database directly ... mainly: because it couldn't really be done in a secure way ... since all code is downloaded, interpreted and executed at the client and therefor JavaScript is per se 'open source' for everyone. how should it connect, how should it manage connections at all? it lacks the most things that it would need to have for DB-interaction since it was never made for it ... but you could do requests (async/sync) to a serverside script (php, asp, jsp, whatever) that will interact with the DB ... and has all the necessary abilities ... so it is no 'disadvantage' since you need to use a combination, or better a 'stack' of technologies when using JavaScript in a modern way today ...

kind regards
Aug 15 '09 #4

Dheeraj Joshi
Expert 100+
P: 1,123
My meaning of saying disadvantage is when it comes to DB connection.(Yeah, it is not intend to do that.)
Aug 15 '09 #5

gits
Expert Mod 5K+
P: 5,320
:) ... just wanted to have that pointed out ...

kind regards
Aug 15 '09 #6

Dheeraj Joshi
Expert 100+
P: 1,123
OH yeah...

Its always good you point out and make others think what they have told is really correct or not.

Regards
Dheeraj Joshi
Aug 15 '09 #7

gits
Expert Mod 5K+
P: 5,320
that is not the point ... as writing code relies on very strict correctness ... the usage of plain words should be too ... and telling that JavaScript has a main disadvantage with DB-connectivity or -interaction or whatever is not true ... since it basicly has NO abilities to do that and is not intended for that purpose ... so even to say that the main disadvantage of a car is that it is not able to drive would be correct ... since it is the driver that drives the car ... or the main disadvantage of sugar is that it cannot give your meal a salty taste ...

kind regards
Aug 15 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.