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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saadkhan
    New Member
    • Aug 2008
    • 40

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

    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.......
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by saadkhan
    Is there any way to create xml file and save it in SQL Server database all using javascript?
    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)

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      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.)

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        '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

        Comment

        • Dheeraj Joshi
          Recognized Expert Top Contributor
          • Jul 2009
          • 1129

          #5
          My meaning of saying disadvantage is when it comes to DB connection.(Yea h, it is not intend to do that.)

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            :) ... just wanted to have that pointed out ...

            kind regards

            Comment

            • Dheeraj Joshi
              Recognized Expert Top Contributor
              • Jul 2009
              • 1129

              #7
              OH yeah...

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

              Regards
              Dheeraj Joshi

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                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

                Comment

                Working...