TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adhikar Patil
NA
481
129.5k
How to convert Json Object to DataTable in Asp.Net Core
Oct 17 2019 10:21 PM
Hello,
I want to convert Json object to DataTable. I have json file to insert bulk data into table using SqlBulkCopy
string contentRootPath = _appSettings.MasterJsonPath;
var folderDetails = Path.Combine(Directory.GetCurrentDirectory(),$"wwwroot\\{"MasterData\\masterdata.json"}");
var JSON = System.IO.File.ReadAllText(folderDetails);
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(JSON);
var response = 0;
DataTable dt = (DataTable)jsonObj["M203StructureKind"].AsDataReader();
SqlBulkCopy bulk = new SqlBulkCopy("Data Source = DESKTOP-JENGCSC;
Initial Catalog=BdsDb; Integrated Security=True;");
bulk.DestinationTableName = "M203StructureKind";
bulk.WriteToServer(dt);
So i am getting exception like Cannot convert type 'Newtonsoft.Json.Linq.JArray' to 'System.Data.DataTable while converting the json object to datatable
Reply
Answers (
2
)
SubString in MVC Core using html and not razor
Can I convert EventArgs type to PaintEventArgs type ?