.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Read the JSON Data from DataBase

Posted By: MOHAMED     Posted Date: September 30, 2013    Points:5   Category :ASP.Net
I used the following code to get the json data from my database.

string cntprop = string.Empty;
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString))
{
try
{
SqlCommand cmd = new SqlCommand("SELECT ID,ItemJSON FROM tblControls", connection);
connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
cntprop = dr["ItemJSON"].ToString();
}
dr.Close();
}
catch (Exception)
{
throw;
}
finally
{
connection.Close();
}
}
return cntprop;
}

The above code return the string data with contains of the JSON data. In my JSON data i want to reterive each item

Sample JSON Data
[{"ControlID":1,"DisplayName":"","ControlType":"TextBox","Text":"","ToolTip":"Enter First Name","TabIndex":0,"CheckDirty":false,"MaxLength":255,"TextCase":"","DefaultValue":false,"NavigationURL":"","ImageSource":"","IsMovable":false,
"ShortcutKey":"","Option":[{"value":"","data":"","value":"","data":"","value":"","data":"","value":"","data":"","value":"","data":""}],"ShowLabel":false,"LabelText":"","LabelPosition":"Left","LabelWidth":"100px",
"LabelHeight":"23px","TextAlignment":"left","LMargin":[{"Left":0,"Top":0,"Right":0,"Bottom":0}],"Font":"Arial","FontSize":"10px","FontColor":"#000","BackGroundColor":"#fff","Width":220,"Height":30,"Margin":[{"Left":0,"Top":0,"Right":0,"Bottom":0}],"Font":"Arial","FontSize":"12px","FontColor":"#000","BackGroundColor":"#fff","Visible":true,"Enable":true,"validate":[{"Required":true,"MinLenght":6,"MaxLenght":8,"Message":[{"Required" :"Required Input"}]}]},{"ControlID":1,"DisplayName":"","ControlType":"TextBox","Text":"","ToolTip":"Enter First Name","TabIndex":0,"CheckDirty":false,"MaxLength":255,"TextCase":"","DefaultValue":false,"NavigationURL":"","ImageSource":"","IsMovable":false,
"ShortcutKey":"","Option":[{"value":"","data":"","value":"","data":"","value":"","data":"","value":"","data":"","value":"","data":""}],"ShowLabel":false,"LabelText":"","LabelPosition":"Left","LabelWidth":"100px",
"LabelHeight":"23px","TextAlignment":"left","LMargin":[{"Left":0,"Top":0,"Right":0,"Bottom":0}],"Font":"Arial","FontSize":"10px","FontColor":"#000","BackGroundColor":"#fff","Width":220,"Height":30,"Margin":[{"Left":0,"Top":0,"Right":0,"Bottom":0}],"Font":"Arial","FontSize":"12px","FontColor":"#000","BackGroundColor":"#fff","Visible":true,"Enable":true,"validate":[{"Required":true,"MinLenght":6,"MaxLenght":8,"Message":[{"Required" :"Required Input"}]}]}]

Responses

No response found. Be the first to respond this post
Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend