- Home
- Forum
- ASP.NET Web Forms
- SpreadSheet - save content to database table
SpreadSheet - save content to database table
ASP.NET Web Forms with VB.NET code.
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
SIGN IN To post a reply.
1 Reply
MV
Madhan Venkateshan
Syncfusion Team
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.
https://www.syncfusion.com/kb/7675/how-to-save-and-retrieve-the-spreadsheet-data-as-json-in-database
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
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
PE Peter
- Dec 23, 2019 05:48 PM UTC
- Dec 24, 2019 03:29 PM UTC