JavaScript Problem -Very Urgent!

Results 1 to 2 of 2

Thread: JavaScript Problem -Very Urgent!

  1. #1
    Join Date
    Dec 1969

    Default JavaScript Problem -Very Urgent!

    Hi,<BR>I would like to insert a data into the Database using Javascript. Is DB connectivity possible in Javascript?<BR><BR>I am pasting a partial piece of the code, it will be great if someone could help me...<BR><BR>&#060;%@ language="JScript" %&#062;<BR><BR><BR>&#060;%<BR>var sCDONTS_Session = "CDONTS.Session";<BR>var obj = Server.CreateObject("Retrieve.UploadRetrieve");<BR >var RES = "";<BR>try {<BR> var totalBytes = Request.TotalBytes;<BR> var requestData = Request.BinaryRead(totalBytes);<BR> obj.LOG ("REQUEST SIZE: "+totalBytes);<BR> obj.ParseRequest (requestData, totalBytes);<BR> var action = obj.Action;<BR> obj.LOG ("ACTION = "+action);<BR> if (action == "CREATE") {<BR> var filename = obj.NextMessageLine;<BR> var oDataStream = obj.DataToTheEnd;<BR>I WOULD LIKE TO INSERT THIS VARIABLE:oDataStream into the Database<BR> obj.Log("FILENAME:"+filename);<BR> var localFileName = Server.MapPath ("../voicefiles/"+filename);<BR> obj.Log("REAL FILENAME:"+localFileName);<BR> var oSaver = Server.CreateObject("Saver.FileSaver");<BR> oSaver.SaveFile (oDataStream, localFileName);<BR> oSaver = null;<BR> obj.Log("SAVED!");<BR> RES = "ACCEPTED";<BR> }<BR><BR>Thanks,<BR>Vaikkam

  2. #2
    Join Date
    Dec 1969

    Default Of course it's possible...

    No different than in VBScript, except for the syntax.<BR><BR>But whether you can do it or not--and how easy it is--depends on what the data type of oDataStream is!<BR><BR>But anyway, you can try:<BR><BR> var conn = Server.CreateObject("ADODB.Connection")<BR> conn.Open( "...your connection string..." );<BR> var rs = Server.CreateObject("ADODB.RecordSet");<BR> rs.Open( "yourTableName", conn, adOpenKeyset, adLockOptimistic );<BR> rs.AddNew();<BR> rs("yourBinaryFieldName") = oDataStream; // may or may not work!<BR> rs.Update();<BR> rs.Close();<BR> conn.Close();<BR><BR>Something along those lines.<BR><BR>But I don&#039;t think much of this Retrieve.UploadRetrieve object you are using! It has about the clumsiest interface of any Upload object that I have ever seen.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts