We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SpreadSheet - save content to database table

Thread ID:

Created:

Updated:

Platform:

Replies:

150170 Dec 23,2019 05:48 PM UTC Dec 24,2019 03:29 PM UTC ASP.NET Web Forms 1
loading
Tags: Spreadsheet
Peter
Asked On December 23, 2019 05:48 PM UTC

ASP.NET Web Forms with VB.NET code.

I have a database table Addresses. How can I use the ej:Spreadsheet component to let the user import addresses to the Addresses table on the database server?

I've made the ASPX page with the ej:Spreadsheet and the AJAX script to upload the spreadsheet to my ASMX webservice:

AJAX script:
        // Save the Spreadsheet data As JSON and send to webservice
        $("#saveSpreadsheetToDatabase").bind("click", function () {
            $.ajax({
                type: "POST",
                url: "Handlers/SpreadsheetFeatures.asmx/SaveSpreadsheetToDB",
                data: JSON.stringify({ sheetData: $("#MainContent_exAddress").ejSpreadsheet("saveAsJSON") }),
                contentType: "application/json; charset=utf-8",
                dataType: 'json',
                success: function (data) {
                    // Success code here.
                    alert("Import succeeded");
                },
                error: function (xhr, status) {
                    alert("An error occurred: " + status);
                }
            });
        });

How can I capture in the ASMX webservice the rows and columns from the sheetData JSON string to insert the data to the Addresses table? The Column names in the spreadsheet have the same name als the table columns.

Table structure:
CREATE TABLE [dbo].[Addresses] (
    [AddressID]   NUMERIC (18)   IDENTITY (1, 1) NOT NULL,
    [Name]        NVARCHAR (255) NULL,
    [IZ]          NVARCHAR (255) NULL,
    [Street]      NVARCHAR (255) NULL,
    [City]        NVARCHAR (255) NULL,
    [PC]          NVARCHAR (50)  NULL,
    [Country]     NVARCHAR (50)  NULL,
    [Phone]       NVARCHAR (50)  NULL,
    [Email]       NVARCHAR (255) NULL,
    [CustomerITG] INT            NOT NULL,
    [Lat]         NVARCHAR (50)  NULL,
    [Lng]         NVARCHAR (50)  NULL,
    [Comment]     NTEXT          NULL,
    CONSTRAINT [PK_Addresses] PRIMARY KEY NONCLUSTERED ([AddressID] ASC)
);

ASPX WebMethod
    <WebMethod()>
    Public Sub SaveSpreadsheetToDB(ByVal sheetData As String)
        Try
            'Insert sheetData to SQL database
        Catch ex As Exception

        End Try
    End Sub



Madhan Venkateshan [Syncfusion]
Replied On December 24, 2019 03:29 PM UTC

Hi Peter, 
 
Good day to you. 
 
We would you like to inform that we have already documented your reported query, please refer the below KB link. 
 
 
If you trying to save it as JSON to server, please refer the below KB link. 
 
If we misunderstood your requirement, please share more details. So that we can work on this and provide you a better solution quickly. 
 
Regards, 
Madhan V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon