Sqlserver update from inside javascript code? - InfoPath Dev
in

InfoPath Dev

Sqlserver update from inside javascript code?

Last post 10-08-2010 04:22 PM by Patrick Halstead. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-07-2010 07:56 AM

    Sqlserver update from inside javascript code?

    I'm trying to update a secondary data connection from inside javascript code connected to a button.   SQLserver database

    I know SQL, but cannot get this update statement to work.  updatedate is a valid datetime variable.    Code segment  -----

    • var query = "update TRANSMARTSPOD SET [EmailDate] = " + updatedate + " ; commit; ";
    • XDocument.DataObjects("TRANSMARTSPOD").DOM.setProperty("SelectionNamespaces",'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" ');
    • XDocument.DataObjects("TRANSMARTSPOD").QueryAdapter.Command = query;
    • XDocument.DataObjects("TRANSMARTSPOD").QueryAdapter.Query();

    Error message during form preview is 

    "The query cannot be run for the following DataObject: TRANSMARTSPOD
    InfoPath cannot run the specified query.
    [0x80040E14][Microsoft OLE DB Provider for SQL Server] Incorrect syntax near '52'.

     

    Filed under: , ,
  • 10-07-2010 10:50 AM In reply to

    Re: Sqlserver update from inside javascript code?

    Hi Maureen52,

    Best practice is not to use code. Why are you trying to update the database connection with javascript? That's not necessary. Best practice is to use Web Services when connecting to databases. Doing updates via code will only cause you pain when the schema changes down the road - as it invariably will. Just don't do it.

    Also, please note: this forum is for InfoPath issues, not SQL database coding via javascript.

    Respectfully,

    Patrick Halstead
    Project Manager at Qdabra
  • 10-08-2010 04:11 AM In reply to

    Re: Sqlserver update from inside javascript code?

     Hi Patrick,

     Wouldn't want to do anything that's not best practice.   And certainly wouldn't want to clutter up the forum with javascript questions.

     I'm  familiar with using Sharepoint webservices from within Infopath... Are there SQLServer webservices that I can invoke from Infopath?

     Or do I have to write my own webservice?  That sounds intense.

     Thanks,

    Maureen57

     

  • 10-08-2010 04:22 PM In reply to

    Re: Sqlserver update from inside javascript code?

    Hi Maureen,

    Yes, we have a free trial of one that you can look at. I'm not trying to sell you that, but it was the first thing we built when we left Microsoft - basically, because everyone needs it. We sell these inexpensive "accelerators" as a way to defray cost of the forum and other development work that we are doing. We have hundreds of people using it and have very low cost options if the trial works for you.

    Best regards,

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.