can you verify my syntax to write to database?

Results 1 to 2 of 2

Thread: can you verify my syntax to write to database?

  1. #1
    Join Date
    Dec 1969

    Default can you verify my syntax to write to database?

    I&#039;m used to VBScript...<BR><BR>&#060;script language="JScript"&#062;<BR><BR>conDB = Application("eCast_ConnectionString"); <BR>conDB.ConnectionTimeout = 2;<BR>conDB.CommandTimeout = 2;<BR>conDB.CursorLocation = 3; <BR> <BR>szSQL = "SELECT * FROM CMRC_Webcasts;";<BR>rs = Server.CreateObject("ADODB.Recordset");<BR> (szSQL, conDB, 3, 3);<BR><BR>rgFields = new Array("Publishname","Description","Author","Copyri ght","Title","PublishPointID","Expiry","TypeOfWebc astID");<BR>rgValues = new Array(Request.Item("presname"), Request.Item("presdetail"), Request.Item("presAuthor"), Request.Item("presCopyright"), Request.Item("presTitle"), Request.Item("presDepartment"), Request.Item("presExpiry"), Request.Item("presTypeOfWebcast"));<BR><BR>rs.addN ew(rgFields, rgValues);<BR>rs.Update();<BR><BR>&#060;/script&#062;

  2. #2
    Join Date
    Dec 1969

    Default Not going to work, at all...

    &#060;script language="JScript"&#062;<BR><BR>HUH? You can&#039;t do this stuff on the CLIENT!<BR><BR>You need to use<BR><BR>&#060;script language="JScript" RunAt=Server&#062;<BR><BR>or<BR><BR>&#060;%@ Language=JScript %&#062;<BR>&#060;%<BR><BR>But certainly not what you showed.<BR><BR>***************************<BR><BR> Then you do this:<BR><BR>conDB = Application("eCast_ConnectionString"); <BR><BR>Make up your mind. Is that application value a *string* (as it seems to be named) or is it an object ref? You appear to think it is an object reference, as the next thing you do is:<BR><BR>conDB.ConnectionTimeout = 2;<BR><BR>But if it is an object ref, then you are making a *HUGE* mistake, storing an open connection object as an Application variable.<BR><BR>ANd if it&#039;s a string, then the first line should be replaced with two lines:<BR><BR>var conDB = Server.CreateObject("ADODB.Connection");<BR>conDB. Open Application("eCast_ConnectionString"); <BR><BR>Finally, in this line:<BR><BR>rgValues = new Array(Request.Item("presname"), Request.Item("presdetail",....<BR><BR>You should *probably* be using, instead:<BR><BR>rgValues = new Array(Request("presname").Value, Request("presdetail").Value, ...<BR><BR>*****************<BR><BR>OOPS! Another goof!<BR><BR>When you use the array form of rs.AddNew, you can *NOT* use rs.Update.<BR><BR>*****************<BR><BR>And another goof!<BR><BR>You probably can&#039;t do this, at all. You are creating JS arrays, and JS arrays are *NOT* COM SafeArray instances. Almost surely AddNew is expecting a pair of COM SafeArray&#039;s and will hiccup on this code. You probably need to set the fields individually, instead of using the pair of arrays.<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