Use javascript to Update To Database

Hi All,
First of all I'm not a javascript user but I have to use javascript for this thing.
Ok I have developed an online application using asp vbscript.
All i want is when a user click on the checkbox i want to do a database update. Obviously I can't do that using client side script and without submitting the page..My friends say the only way is to use Java applet and I never do Java applet before! :)
But i do want to learn..Do anybody have any related websites on this or examples for Java applet dummies..?? I'll appreciate it a lot..
Thks..

asp vbscript.AHHHGGGG! (j/k)
>
All i want is when a user click on the checkbox i want
to do a database update. Obviously I can't do that
using client side script and without submitting the
page..What do you mean? You have no access to the server?
A db update from an HTML page, IMHO, can't be done without some server side work...

Similar Messages

  • Using javascript to set non database values

    I finally figured out how to set the values of a non database form field using Javascript. The only problem is, I want this
    field to be a display only field, and the value does not get set if I make the field non updateable on the form. Can
    somebody please help me!! This is urgent.

    Stan,
    One way to do this is to call the doSubmit() function and create a page branch to handle your request. This way you can use apex validations and other goodies if your requirements change. Also this will save the state of your items on the page you are leaving.
    Edit
    I forgot to mention that you can pass a string parameter to the doSubmit function. The parameter will be the request sent to apex. For instance you could use doSubmit('DO_SOMETHING') and you can have a page branch which will fire if the request is equal to DO_SOMETHING.
    Cheers,
    Tyson Jouglet
    Edited by: Tyson Jouglet on Dec 1, 2009 10:11 AM

  • Adobe Reader Submit Button using JavaScript

    We have a form that when submitted it needs to use javascript to update the Subject Line of the email message for our workflow process. This process works absolutely great when using Acrobat. However, when sent to someone using Reader (even with JavaScript enabled through preferences) nothing happens when the button is clicked. The form was designed in Acrobat 10 Professional.
    Here is the JavaScript we are using...
    var wsuid = this.getField ("mywsuid");
    var d = new Date();
    var month = d.getMonth()+1;
    var day = d.getDate();
    var year = d.getFullYear();
    var today = ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + '/' + day +  year;
    var name = this.getField("name");
    var subject = "subject: " + (wsuid.valueAsString) + ":" + (name.valueAsString) + ":" + (today);
    this.mailDoc({
        bUI: true,
        cTo: "[email protected]",
        cCc: "",
        cSubject: subject,
    Suggestions on getting this to work with Acrobat Reader is much appreciated.
    Dawn Bleuel
    Wichita State University

    I was able to open the JavaScript debugger in Acrobat Pro. When the document is Reader Enabled, I get the following message:
    Acrobat EScript Built-in Functions Version 10.0
    Acrobat SOAP 10.0
    NotAllowedError: Security settings prevent access to this property or method.
    Doc.subject:15:Field Submit:Mouse Up
    And in Acrobat Pro - I now see Protected View is set to Off.

  • Updating a Date Column in SP2010 using Javascript in WP

    Hi,
    I know that Today() doesn't work in SP. But seeing all the various JS codes to highlight rows etc is rather cumbersome, especially if you have several operations that you may want to run based on Today().
    In my list, I have a column which is hidden from public view, 'thisDate'. This column is set to Date Only and with each new item that is added, it loads today's date. That's fine at item creation; but what I want to do is use JS to
    update all fields in thisDate column with today's date whenever the list is first loaded on any new day.
    <script type="text/javascript" language="javascript">
    var tDate = null;
    allItems = null;
    ExecuteOrDelayUntilScriptLoaded(UpdateList, 'sp.js'); //this is necessary to ensure the library is loaded before function triggered
    function DateThis(){
    tDate = new Date().toJSON();
    tDate.format("m/dd/yy");
    return tDate;
    function UpdateList(){
    var tContext = new SP.ClientContext.get_current();
    var tSite = tContext.get_site();
    var tWeb = tSite.get_rootWeb();
    var tList = tWeb.get_lists().getByTitle('TeamDUCOM LNO Travel');
    var tQuery = SP.CamlQuery.createAllItemsQuery();
    this.allItems = tList.getItems(tQuery);
    tContext.load(allItems, 'Include(thisDate)');
    tContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySuccess), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySuccess(){
    var listEnum = allItems.getEnumerator();
    var todaysDate = DateThis();
    while(listEnum.moveNext()){
    var currentItem = listEnum.get_current();
    var origDate = currentItem.get_item('thisDate');
    currentItem.set_item('thisDate',todaysDate);
    currentItem.update();
    tContext.executeQueryAsync(Function.createDelegate(this, this.ListItemsUpdateSuccess), Function.createDelegate(this, this.ListItemsUpdateFailed));
    function onQueryFailed (){
    alert('Query List Failed ');
    function ListItemsUpdateSuccess(){
    alert('Success ');
    function ListItemsUpdateFailed(){
    alert('Update List Failed ');
    </script>
    Right now, I get an 'onQueryFailed' alert saying the Query list failed.  Also in the watch windo, I get null for 'tDate and 'todaysDate' is undefined.
    Once I can get this to work, it is my intention to add an extra line or two to compare variables
    origDate with todaysDate. If they match, skip and go to next.  I think this would reduce updates and minimze the List sending out email alerts (most of my users use Alerts to be notified of changes to the list. (Bonus
    would be being able to suspend any alert triggers at update, but I don't believe that's possible, or?)
    After all the debugging, I also intend to comment out the alerts within the code, since no one needs to see that.
    Ideally, this code would be reuseable on any list that needs countdowns, traffic lights, colorcoding etc, or even calcaulated columns using
    thisDate data in lieu of the nonexistent Today()
    function. And, as mentioned above, the list only needs to be updated once for the 1st person to open the list on any given day.
    TIA
    AH-C

    Victoria,
    That didn't work for me. When I stripped out the script tags fro the file and placed it around the script url, I kept getting an error message within the webpart while in page edit view: "Cannot retrieve the URL specified in the Content Link
    property. For more assistance, contact your site administrator."
    I tried both your suggested change and the older script every which way - before the list, after the list, hidden and not. I then focused more on the IE 9's F12 developer tool and watched as it stepped thru the code. Everything was fine with the variables
    (each object loaded in the Locals view) until it came time to call the executeQueryAsync.
    I even traced down the stack and confirming the arguments. But a thot kept bugging me about "get_rootweb". i had seen other examples where it was "get_web" instead. When I went back to search Bing, I came across an example where the coder
    just cut to the chase, bypassing varibles (in my case, dropping 'tSite' & 'tWeb'), so my trimmed code snippet now looks like this:
    var tContext = SP.ClientContext.get_current();
    var tList = tContext.get_web().get_lists().getByTitle('MyList Name');
    var tQuery = SP.CamlQuery.createAllItemsQuery();
    this.everyItem = tList.getItems(tQuery);
    Prior to that, I also changed the var 'allItems', because I wondered if that was causing conflicts, case-sensitivity notwithstanding, since my default list view was 'AllItems.aspx'
    Anyway, it now works regardless of CEWP positioning/hidden status (using only the reference to JS file in SiteAssets and using the script tags within the js file, not the CWEP link) -- typically, I make such CWEPs (ie EasyTabs) hidden and at the bottom of
    the page, after the list and it works just fine.
    I'm going to mark this thread as answered. But before I do that, I'll work out the one piece I need to add for the code to do nothing to a particular item if 'todaysDate' matches 'origDate' then post the entire code as the solution.
    Thanks again.
    Best regards,
    AH-C
    PS, I got a deluge of email alerts telling me that the list was updated. I anticipated that and will be looking for code to stop that if possible.  But with the test for matching dates, at least I can limit the deluge of emails to once a day by whomever
    is 1st to check the list that day (my alert is configured for instant alerting whenever a change has been made and I'd prefer to keep it that way, unless there's no workaround.

  • Using JavaScript to access Database

    Hi all,
    I am using JSP and Tomcat for my web application.
    Now i need to use Javascript to access the MS Access database. Can anyone please tell me the class and command for accessing database from javascript.
    Please give me an example and that will help me. I know it is not good to access database using JavaScript. But in this situation i have to use it anyhow.
    Thatnks

    Hi all,
    Thanks very much for your help. Now some of you said that it is not possible in JSP to access database using JavaScript, some of you said yes it is possible but not secure, I understand the both concepts.
    Now my problem is last year i built a web application for my company and the scenario is like this:
    The staff records their working time in that application. Now when they click a button it creates a drop down list of all clients they have and that list is in HTML as SELECT TAG. So the select tag includes 100+ client name.
    Now they can add as many client as they want for example if i have worked with 10 clients i will create 10 drop down list by pressing button called ADD CLIENT and will record their hours.
    Now from the description above you guys can understand that an OnClick Javascript event in involved to create multiple dropdown list.
    Now what i want is that i want those 100+ client list to come from database rather than typing them in the SELECT TAG. and please remember the SELECT tag is implemented in Javascript using innerHTML event.
    Now for those of you who suggested that it is not possible to use Javascript in accessing database, can you please tell me how can i implement Onclick event using JSP/Serverlet and can create dynamic drop downlist?
    Thanks for your time to read this long message.

  • Updating a database using EJB Inheritance

    I am new to EJB's, so please forgive my ignorance. I creating the following classes that inherit from each other along with a method to update my database:
    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    @DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
    public abstract class ObjectA implements java.io.Serializable {
         protected String name;
         protected String desc;
         protected String type;
    @Entity
    @DiscriminatorValue("OBJECTB")
    public class ObjectB extends ObjectA implements java.io.Serializable {
         protected String str_b;
         public ObjectB(String name, String desc, String type, String str_b) {
              this.name = name;
              this.desc = desc;
              this.type = type;
              this.str_b = str_b;
    @Entity
    @DiscriminatorValue("OBJECTC")
    public class ObjectC extends ObjectB implements java.io.Serializable {
         private String str_c;
         public ObjectC(String name, String desc, String type, String str_b, String str_c) {
              this.name = name;
              this.desc = desc;
              this.type = type;
              this.str_b = str_b;
              this.str_c = str_c;
    public class MyFacade implements ServletContextListener {
         @PersistenceUnit(unitName="Pu")
        private EntityManagerFactory emf;
        @Resource
        private UserTransaction utx;
        public MyFacade() { }
        public void contextDestroyed(ServletContextEvent sce) {
            if (emf.isOpen()) emf.close();
        public void contextInitialized(ServletContextEvent sce) {
            ServletContext context = sce.getServletContext();
            context.setAttribute("MyFacade", this);
         public void updateObject(ObjectA obj) {
            EntityManager em = emf.createEntityManager();
            try{
                utx.begin();
                em.merge(obj);
                utx.commit();
            } catch(Exception exe){
                try {
                    utx.rollback();
                } catch (Exception e) {}
                throw new RuntimeException("Error updating obj", exe);
            } finally {
                em.close();
    }If I do the following:
         String name = "test name";
         String desc = "updating object c";
         String type = "OBJECTC";
         String b = "b";
         String c = "c";
         MyFacade myf = new MyFacade();
         ObjectC objC = new ObjectC(name, desc, type, b, c);
         myf.updateObject(objC);
         .....In my database, only the values associated with ObjectC get updated and nothing from ObjectA or ObjectB get updated in the database. Does the "merge" method not work on inheritance. How do I update my database using inheritance?
    Thanks!
    Message was edited by:
    FourierXForm

    did you only have ISQL for testing it?
    Can you debug the form and look, if someone happens - exceptions, ... ?
    after the update you can use
    message (SQL%ROWCOUNT); pause ;
    to look, how many records were updated

  • Unable to update rating (rating column) on host document using JavaScript Object Model API inside sharepoint hosted apps

    Hi Everyone,
    We are developing SharePoint hosted apps for Office 365, for that we are going
    to implement document rating functionality inside Sharepoint app. The host web contain document library (“Documents”) and from apps we need to rate each document. The rating functionality working fine with CQWP in team site  using
    JavaScript Object Model API.
    But the same code is not working inside apps and giving error:-
    If we are using app context than error will be:-
    "List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user."
    And for Host context than error will be:-
    "Unexpected response data from server."
    Please help on this
    Please see below code..
    'use strict';
    var web, list, listItems, hostUrl, videoId, output = "";
    var videoLibrary = "Documents";
    var context, currentContext;
    var lists, listID;
    var list, parentContext;
    var scriptbase;
    (function () {
        // This code runs when the DOM is ready and creates a context object which is 
        // needed to use the SharePoint object model
        $(document).ready(function () {
            hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
            context = SP.ClientContext.get_current();      
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
        function sharePointReady() {
            scriptbase = hostUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            $.getScript(scriptbase + "SP.Runtime.js", function () {
                $.getScript(scriptbase + "SP.js", function () {
                    $.getScript(scriptbase + "SP.Core.js", function () {
                        $.getScript(scriptbase + "reputation.js", function () {
                            $.getScript(scriptbase + "sp.requestexecutor.js", execCrossDomainRequest);
        //Query list from hostweb
        function execCrossDomainRequest() {       
            //Load the list from hostweb
            parentContext = new SP.AppContextSite(context, hostUrl);
            web = parentContext.get_web();
            list = web.get_lists().getByTitle(videoLibrary);
            context.load(list, 'Title', 'Id');
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/></OrderBy></Query><RowLimit>1</RowLimit></View>');
            listItems = list.getItems(camlQuery);        
            context.load(listItems);
            context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        //Process the image library
        function onQuerySucceeded() {       
            var lstID = list.get_id();
            var ctx = new SP.ClientContext(hostUrl);       
            var ratingValue = 4;
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function() {      
            Microsoft.Office.Server.ReputationModel.Reputation.setRating(ctx, lstID, 1, ratingValue);       
            ctx.executeQueryAsync(RatingSuccess, RatingFailure);
        function onQueryFailed(sender, args) {
            alert('Failed' + args.get_message());
        function failed(sender, args) {
            alert("failed because:" + args.get_message());
        function RatingSuccess() {
            alert('rating set');
            //displaystar();
        function RatingFailure(sender, args) {
            alert('Rating failed : : ' + args.get_message());
        //Gets the query string paramter
        function getQueryStringParameter(paramToRetrieve) {
            var params;
            params = document.URL.split("?")[1].split("&");
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve) return singleParam[1];
    Thanks & Regards
    Sanjay 
    Thank you in advance! :-)
          

    Hi,
    According to your post, my understanding is that you want to update list column in SharePoint hosted apps using JavaScript Client Object Model.
    Based on the error message, it seems not retrieve the list object in context. I suggest you debug the code step by step using Internet Explorer Developer Tools to
    find the problem.
    Here are some demos about using JavaScript Client Object Model in SharePoint hosted app:
    http://blogs.msdn.com/b/officeapps/archive/2012/09/04/using-the-javascript-object-model-jsom-in-apps-for-sharepoint.aspx
    http://sharepoint.stackexchange.com/questions/55334/how-to-access-list-in-sharepoint-hosted-app
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    Best regards
    Zhengyu Guo
    TechNet Community Support

  • Using Tabstrip update the database table

    Hi Guy's,
    I created two screens(100 & 110).
    Click 1 pushbutton HRP1000 related information is displayed.
    Click 2 pushbutton it displays HRP1001 relatd information.
    worked to read the data from the Database tables and output displayed sucessfuly .   However i want to entered data in those fields wants to update to database table.
    Please friends help me how to work this senario.
    Thanks and Regards,
    Sai.

    Hi Guy's,
    To update the database records, wrote the logic in PAI
       WHEN 'SAVE'.
        INSERT HRP1001.
    INSERT INTO HRP1001  VALUES wa_P2.
    it displaying an error message " the work area wa_p2 is not long enough.
    and also i tried using it_p2
    it displaying an error message " you can't use internal table as work area".
    Please help me friends  it is very urgent.
    Thanks and Regards,
    Sai.

  • Getting errors while updating links in Indesign document using javascript

    Hi,
    We are updating the links in InDesign document using javascript. After running the script, we are getting the below errors in Adobe InDesign CC debug.
    When closing the document for first time we are getting the below mentioned errors,
    ASSERT 'fRefCount == 0' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRICache.tpp at line 230 failed.
    Erased item list not empty at block delete time
    blockUID = 10486786 not freed
    Internal error: 904 items were leaked!
    After that we are opening the same document for second time, then we are getting the below mentioned errors,
    ASSERT 'ts_DBPubFile->PlacementUIDIsAvailable(uid)' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRIUtils.tpp at line 195 failed.
    DB failed to create UID!
    ASSERT 'this->FindInIDRangeList(fLastCreatedBlockUID) >= 0' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRICache.tpp at line 476 failed.
    ASSERT 'fLastCreatedBlockUID != kInvalidUID && fLastCreatedItemID != 0' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRICache.tpp at line 467 failed.
    ASSERT '(SaLRIUtils<SnapshotID , SnapshotInfo>::ts_DB)->IsValidUID(itemUID)' in ..\..\..\source\components\database3\revisioneddatabase\SnapshotCache.cpp at line 55 failed.
    Please help us to solve this error in InDesign debug.
    Thanks,
    Vimala L

    You're probably better off raising this in the SDK forum.

  • Updating different Databases Using XI

    Hello,
    I am having one requirement for updating different databases using XI.
    The scenario is that
    Data is coming from ERP to XI.
    This data should be inserted or updated in SQL server.
    Depending on certain conditions I need to update different SQL servers.
    Currently I am having one interface which updates one SQL server database.
    I want to change that interface for updating different SQL server databases depending on the data coming from ERP.
    Is it possible?
    How can I achieve this?
    Thanks in Advance
    Abhijit.

    Hi abi,
        For using more than one database server u can use the BPM.
        there in the design phase, while u making the layout of the picture type connection , there in the switch tool , u can put the condition and according to that
    it will connect to the database server.......
    if it is useful give the rewards
    Regards
    Sasi.........

  • AUXILIARY database update using full backup from target database

    Hi,
    I am now facing the problem with how to implement AUXILIARY database update to be consistent with the target database during a certain period (a week). I did a fully backup on our target database everyday using rman. I know it is possible to use expdp to realize it but i want to use the current fully backup to do it. Does anybody has idea or experience with that? Thanks in advance!
    Regards,
    lik

    That's OK. If you don't use RMAN to clone your database. You can create a database just using the cold backup of the primary database simply.
    Important things are
    1) you must catalog all datafiles as image copy level 0 in the cloned database
    RMAN> connect catalog rman/rman@rcvcat (in host 1)
    RMAN> connect target sys/manager@clonedb (in host 2)
    RMAN> catalog datafilecopy
    '/oracle/oradata/CLONE/datafile/abc.dbf',
    '/oracle/oradata/CLONE/datafile/def.dbf',
    '/oracle/oradata/CLONE/datafile/ghi.dbf'
    level 0 tag 'CLONE';
    2) You need to make incrementals of the primary database to refresh the clone database.Make sure that you need to specify a tag for the incremental and the name of tag is the exactly same as the one used step (1).
    RMAN> connect catalog rman/rman@rcvcat (in host 1)
    RMAN> connect target sys/manager@prod (in host 3)
    RMAN> backup incremental level 1 tag 'CLONE' for recover of copy with tag 'CLONE' database format '/backup/%u';
    3) Copy the newly created incrementals (in host 3) to the clone database site (host 2). Make sure the directory must be exactly same.
    $ rcp /backup/<incr_backup> /backup/
    -- rcp <the loc of a incremental in host 3> <the loc of a incremental in host 2>
    4) Apply incrementals to update the clone database. Make sure you provide the tag you specified.
    RMAN> connect catalog rman/rman@rcvcat
    RMAN> connect target sys/manager@clone
    RMAN> recover copy of database with tag 'CLONE';
    5) After update the clone database, then delete the incremental backups and uncatalog the image copies
    RMAN> delete backup tag 'CLONE';
    RMAN> change copy like '/oracle/oradata/CLONE/datafile/%' uncatalog;
    *** As you can see, you can clone a database using any methods. The key is you have to catalog the clone database when you refresh it. After finishing it, then uncatalog..

  • How to display Images stored in a database using javascript

    Hi.
    I have some images stored in a table and I need to display them using javascript. The images are stored in BLOB columns: I would like to know if I can put them on a directory and then get it from there using BFILENAME function.
    Any suggestion?
    Regards,
    Jeannine

    Hi All,
    Yes DuraiRaja - i am using the document.getElementById(' ').
    In my app, I have a Main controller calling a View - Default.HTM,
    This Default.HTM, in turn loads up three trays T1, T2, T3 and these tray elements in turn call up the controllers ctrl1, ctrl2, ctrl3 associated to them.
    CTRL1 calls a view - View1 - V1.htm, which has the below code.
    And on the below page all that i am trying to do is validate if "FieldVal" is blank or not.
    I get an error on IE as "Object required"
    I get a HTTP 501/505 error when i try to upload the code.
    Thanks all !

  • How to use the myAdapter.Update and OleDbCommandBuilder from dataGridView to update the db2 database

    hello,everybody ,it a question makes me crazy .my code is that :
            public string tableName = "";
            public DataSet ds;
            public OleDbDataAdapter myAdapter;
            public string sql = "";
            private   void button12_Click_1(object sender, EventArgs e)
                sql = textBox5.Text.Trim();
                OleDbConnection Conn = new OleDbConnection(st_contractconn);     
                Conn.Open();
                this.comboBox1.Items.Add(this.textBox5.Text);
                try
                    System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"(?<=from\s)\w+(?=\s)");
                    System.Text.RegularExpressions.Match B = r.Match(sql);
                    tableName = B.ToString();
                   OleDbCommand cmd = new OleDbCommand("SELECT * FROM PT_PO",Conn);
                   Conn.Close();
                    myAdapter = new OleDbDataAdapter(cmd);
                    ds = new DataSet();
                    myAdapter.Fill(ds, "PT_PO");
                    dataGridView2.DataSource = ds.Tables["PT_PO"].DefaultView;                   
                    this.groupBox2.Text = "共查询到" + ds.Tables[0].Rows.Count.ToString() + "条记录" + tableName;
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
            private void button26_Click(object sender, EventArgs e)
                OleDbConnection Conn = new OleDbConnection(st_contractconn);
                Conn.Open();
                OleDbCommandBuilder Builder = new OleDbCommandBuilder(myAdapter);
                Validate() ;            
                myAdapter.Update(ds.Tables["PT_PO"]);
                Conn.Close();
                ds.AcceptChanges() ; 
    when it run to the myAdapter.Update(ds.Tables["PT_PO"]);  it comes out a wrong "对于不返回任何基表信息的 SelectCommand 不支持动态 SQL 生成。" who knows  it is why ,my QQ is 501212848,thankyou very much.

    Hello,
    We were a IBM-DB2 shop for over 20 years, when we moved to .NET we found it was better to use the native DB2 data provider which you can download from IBM for free.
    Main objects
    IBM.Data.DB2.iSeries.iDB2Connection
    IBM.Data.DB2.iSeries.iDB2Command
    IBM.Data.DB2.iSeries.iDB2Parameter
    So you would not use adapters but write code using the key objects above. Then to get new primary keys we would use
    SELECT nextval for SOMETABLE_REF_AUTONUMBER_SEQUENCE from sysibm.sysdummy1
    Bottom line is the structure is create a connection, create a command, set the connection and command text along with creating parameters as needed.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.
    what is the meaning about you ? db2 cannt using adapters  to update the datebase?

  • Avoiding concurrency errors when updating a database through AJAX

    What are some strategies for avoiding concurrency errors when updating a database through AJAX. That is, in cases where a given user could attempt to modify the same row in the database with simultaneous requests (say, that he updates one column with information with an AJAX call, then immediately submits a form that updates the same row), what are some good ways yo prevent the two updates from colliding? On the JavaScript side one might make the AJAX call synchronous, but I question whether that is the best way to do it. Has anyone else confronted this?

    Well, since no one seems to have any ideas so far, I'll throw in my two cents worth.
    I'm not too familiar with AJAX so my advice may be limited.
    I suggest you do a google search on Optimistic concurrency database to get some ideas on how to handle it.
    If your update/insert/delete query is thread safe, then even if the same user double clicks the button fast enough to immediately have another update to the same record, then the first update will complete before the second one is carried out. Therefore no harm is done since he is just updating the same record. Since a typical update/insert/delete takes only a few milliseconds (querying may take a lot more time), its not likely he can click the button that fast. (I assume your using connection pooling for speed).
    The trouble comes up when two people call up data from the same record in different browsers. The first one updates/inserts/deletes the record. Now the other user is looking at old data. When he updates/inserts/deletes, there is a problem. One way to handle this is to keep a copy of all the fields from that record in each user's session scope when they first fetch it from the database (example: oldName). Then when you go to update some time later, to this:
    sql= update person set name=newValue where personID=3344 and name=oldName
    Note oldName is from session scope.
    If name in the database has changed, the update will not occur and will return 0 records updated. If it didn't change, it will update.
    Note your update function should not throw an exception if it cant update, it should return false. Return true if it worked.
    Example: public boolean updateName(String name)
    Similiarly, your insert should not throw an exception if the record already exists, it should return false meaning it cant insert.
    Exaple: public bolean insertName(String name). Same thing with delete function.
    If a record cant be updated due to someone else updating the record while the user was looking at data, return a message that it wasn't updated due to that problem. Then show the user the new value in the database ask him if he wants to overwrite the new change.
    Note even if you show 100 records on the JSP, only update the ones that have changed and not all 100. This way, its not likely he has updated the same records someone else has altered. Less likely a colision compared to updating all 100.
    If your updating/inserting/deleting more than 1 record (say, 3), then you should look into setting up a transaction in addition to all the above and rolling back all of them if one fails.
    Reading the section on databases from http://www.javapractices.com/home/HomeAction.do may also help.

  • Error while updating a database

    hi,
    i am getting an error "Object reference not set to an instance of object" while updating a database. here is my code..
    QryStr = "update OSRI set U_sqf = Val('" & sqft & "'),U_sqm = Val('" & sqmt & "') where ItemCode = '" & Code & "'"
                RecSet.DoQuery(QryStr)
                Res = True
    Edited by: puneeth shankar on Jul 2, 2008 7:27 PM

    Hi
    Maybe you are missing these sentences ..
    Dim RecSetAs SAPbobsCOM.Recordset
    RecSet= SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
    and then
    QryStr = "update OSRI set U_sqf = Val('" & sqft & "'),U_sqm = Val('" & sqmt & "') where ItemCode = '" & Code & "'"
    RecSet.DoQuery(QryStr)
    Res = True
    But I think you are trying to update directly using an Update statement to a SAP table.  You must check the documentation.  I think this is not allow.  You must then use an alternate way !

Maybe you are looking for

  • Routing issue between two satellites sites and one central hub

    Hi, I have 3 Ad sites with one exchange 2010 hub,cas,mailbox server on each sites. One of this site (site A) is central Hub and the two other sites  ( B and C) are two satellites of site A. The is no connectivity between site B and C, only connectivi

  • Transferring library to a new computer 2014

    I don't see any way to actually contact Customer Service if I do not have a serial number for an iPad, iPhone, Mac, etc. I have PC laptops. I can access iTunes, buy songs, etc. and have a library. Here is the question/problem: About 3 months ago, my

  • Backup tool for ASA config?

    Hi, We are using Solarwinds Kiwi backup tool to backup our ASA configs, however it has hit a bug which they are looking into as it only backs up half of the config.  While they search for a fix does anyone know of another free tool I can use to sched

  • Adobe After Effect CS5 - Error Instal.

    Hello! I have a problem when install AAE CS5 on my PC with Windows 7 32bit. Translate: Adobe After Effect can only be installed on system 64bit. Any suggestions ? Yours, Zikk

  • ORACLE SERVER ERROR

    pls tell how can i trap and handle the error returned by oracle server in my forms with the oracle error no and the associated message with that error. thank you with regards