Link to home
Start Free TrialLog in
Avatar of arnololo123
arnololo123

asked on

Updating sql table via webservice from JAvascript

Hello,

I have a gridview and I am using a modalpop extender with a webservice to do the updates.
The webservice work great to grab the data and show it in the  modal popup. I cam calling the webservice from the javascript so it is very fast.

But how can I use the webservice to  do the update of the data, I have about 30 columns.

Regards
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

So if I understood correctly you're already doing the ajax calls to fill the grid and fill the popup.
These are all GET requests right?

So basically now you need to create a new method to handle the update passing the form data.
Hi,

In addition to what Alexandre has said, if you would need more specific help (for instance how to write a method to update the table), you should also provide us with info on what kind of technologies do you use in what you already have.

If you are fetching data with Entity Framework, it would be meaningful to also update data using Entity Framework. If you are using SqlCommand in order to fetch your data, it would also be meaningful to use this in order to update it.

In the same manner, what is your webservice? Is it WCF, is it WebAPI? is it something else?

Giannis
Avatar of arnololo123
arnololo123

ASKER

HEllo, I am filling the grid with  a regular sqldatasource. I am currently only using the webservice to  fill the modalpopup extender for editing the data.
The popup is open via javascript and the webserivce is called via javascript which makes the popup very fast even with hundred's of row.
Could you pls share the code of your service?
Hello, here is the code for the webservice.
I am using C#, asp.net, the webservice was created from Visual studio by just selecting the option "Webservice"
using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Drawing;
using System.IO;


/// <summary>
/// Summary description for BOPCSVData
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
 [System.Web.Script.Services.ScriptService]
public class BOPCSVData : System.Web.Services.WebService {

    public BOPCSVData () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
   

    public string GrabData(int idrow)
    {
        string query = "SELECT     idBOPCSV, FKidprogram, FKidversion, typepart, segment, BOMNumb, FaurPartnumb, partdesc, CustPartNumb, FKIDSupplier, AcquiSupplier, SupplierProfile, SupplierLocation, DateNominated, breakdown, QtyperCar, TakeRate, FCA, Freight, Packaging, ImportDuty, Warehousing, FAUPlant, PPA1, FReC, target, PurchCommit,  IncoTerm, PaymentTerm, Currency, Comment, LTA1, LTA2, LTA3, LTA4, LTA5, BTcurrency, BTSales, BTtarget, BTSourcedCost, BTterms, BTcomments, BTSupplier,    BTSupplierLocation, BTPO, BTPODate, BTNewModOth, LTAScope, Sourced, SNCForecast, PPA2, PPA3, PPA4, PPA5, PPA6, IncoLocation, LTADate1, LTADate2,  LTADate3, LTADate4, LTADate5, LTASour1, LTASour2, LTASour3, LTASour4, LTASour5, LTASourDate1, LTASourDate2, LTASourDate3, LTASourDate4, LTASourDate5,    LTAScopePurch, LTAScopeTarget, DrawingIndex, CommentsTransfert FROM    TPTData1 WHERE iddata = " + idrow;
        SqlDataAdapter da = new SqlDataAdapter(query, new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString));
        DataSet ds = new DataSet();
        
        da.Fill(ds);
        return ds.GetXml();
    } 

}

Open in new window

SOLUTION
Avatar of Athar Syed
Athar Syed
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Thanks, but this sample  uses Jquery, I  would like to stay with the javascript to call the webservice for update.
Also I have over 30 fields, and I was hoping to find a solution where I Would not have to pass 30 parameters.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would like  not to use Jquery, just javascript and webservice.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial