VS 2005 Reading Json Format?
Apr 13, 2010My approach in reading a json format is parsing into an array. My question is this the right way of reading json format?
View 5 RepliesMy approach in reading a json format is parsing into an array. My question is this the right way of reading json format?
View 5 RepliesI'm completely new to both VB.NET and JSON, and I'm trying to figure out how to do SQL queries towards an SQL 2005 Express server and format the return value to JSON. I got the queries working using this (perhaps very newbie-like) code;
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Partial Public Class SQLConnect
Inherits System.Web.UI.Page
'Defines SQL variables
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim ReadData As String
Dim i As Integer
Sub Click(ByVal s As Object, ByVal e As EventArgs)
'Define SQL address, database, username and password
con.ConnectionString = "Data Source=localhostSQLEXPRESS;Initial Catalog=tempdb;User ID=tesst;Password=test"
Try
'Initialize connection
con.Open()
'Specify SQL query
cmd = New SqlCommand("SELECT * FROM Member", con)
'Execute query, dump result array into variable
dr = cmd.ExecuteReader()
messageLabel.Text = "<br />Connection established<br />"
While (dr.Read)
i = 0
For i = 0 To dr.FieldCount - 1
'Dump query results into a variable
ReadData += dr.Item(i).ToString
Next
End While
'Print query results
messageLabel2.Text = ReadData
'Close connection
con.Close()
Catch ex As Exception
messageLabel.Text = "<br />Connection failed<br />"
End Try
End Sub
End Class
I have been looking at this, and I would love to see some code examples using this class or any other good method.
I want to retreive the data from database and assign it to dropdownlist. For that I'm using the following jquery in the onclick event
[Code]....
I'm using jquery autocomplete to call a .aspx page which returns some matching words.
The jQuery stuff relies on a JSON feed to work. Currently, in my C# I'm formatting the output as a string, which ouputs something like this:
{ query:'aa','aardvark','aardvarks']}
I was hoping that because the string is formatted in the JSON format, that would be good enough for the Javascript to process but it appears not.
how to format this text in C# into proper JSON format which JavaScript can deal with properly?
I want to read data from an excel sheet which is in non-standard format. I have tried many things but could not find a solution,
View 1 RepliesI have a page that does an upload of an xlsx file to a datatable and write into SQL.
That is working, my problem is when i upload the file and pass the values to the datatable some of them are showing in the wrong format and the column name dont
appears.
e.g.:
Hours at home
Hours working
3:00
8:00
01-01-1900 1:35:00
01-01-1900 2:35:00
01-01-1900 3:35:00
The first 2 columns its how i want the info the third is how my problem looks like.
I've tested and the problem occurs when the same column has more than one value.
The format of the cells is h:mm if i change it to text it works fine but i dont want that because the time will be converted to semething like this 0,123456789.
I dont know if it matters but the xlsx file is kinda complex and has 10,2MB.
I'm working with big blobs of JSON. These blobs change slightly over time and a revision history is kept. I'd really like to be able to do a visual diff on them, but my problem is they're being stored without any formatting at all - everything is on one line, so that makes it a little hard to see what changed.
View 3 RepliesI'm using a FCKEditor. I added some word document files in the server. I need to read the content of the work document in HTML format and assign it to the FCKEditor.
View 4 RepliesI am trying to import the excel file whose format is not in row column order in asp.net 3.5
I tried to read the file using OleDBDataAdapter but it given me the error "External file is not in proper format" something like that..
How to return values from Webmethod to the client in JSON format? There are two static int values that i want to return.Do I need to create new object with those 2 properties and return it?The GetStatus() method is called frequently and i don't like the idea of creating a special object each time just for json formatting...
[WebMethod]
public static int GetStatus()
{
int statusProcess,statusProcessTotal;
Status.Lock.EnterReadLock();
statusProcess=Status.Process; //Static field
statusProcessTotal=Status.ProcessTotal; //Static field
Status.Lock.ExitReadLock();
return ...
}
On client side I catch the return value in :
function OnSucceeded(result, userContext, methodName)
(PageMethods.GetStatus(OnSucceeded, OnFailed);)
How can i convert select options elements to JSON text.
[code]...
I want to set options belong to select which is not runat=server to the And I want to split string to array.
I was using Extjs to send a json object to my asp.net webservice/Update method , but I find the following error in firebug reseponse.
[Code]....
I have a simple webservice that I would like to upload a file to. The problem is that I need the response in json.
Form my experience in order to get a response in Json my request has to have a content-type of 'application/json'. But ofcourse this cannot be the case with a file upload since the content type will have to be 'multipart/form-data'.
In my Json i want to return a value showing whether successful and a filename.
[code]...
i Declare in.cs file
TextBox tb=new TextBox();
and how to get aspx when page is load
<input type="Text" runat="server"/>
using jquery json
I have the following web method , no success on return a correct Json format.
[Code]....
GetAll() return list of type "Company" POCO classes.
The web method complaint type "Company" could not cast to object. However I could not just return the Company type because client side Json only accept its 2 properties -"CompanyName", "ID" and I want to keep it that way.
Of cause, I had tried create a CompanyDTO which only have those two properties, but same error - "Unable to cast object of type..."
How should I modify in my web method to make it able to return a list of partial "Company" type in Json format?
how would i go about returning a generic list in json format, can anyone point me to any good examples.
View 2 RepliesIn my application, while reading body of mail. I am getting the text of the body as "This is a multipart message in MIME format."
Here is my code
SmtPop.POP3Client pop = new SmtPop.POP3Client();
pop.Open(serverName, 110, emailId, passWord);
SmtPop.POPMessageId[] messages = pop.GetMailList();
if (messages == null) return;
foreach (SmtPop.POPMessageId id in messages) {
try { Byte[] b = new Byte[0];
SmtPop.POPReader reader = pop.GetMailReader(id);
SmtPop.MimeMessage msg = new SmtPop.MimeMessage();
msg.Read(reader); Boolean kasbook=false;
String caseCode =null; string body = msg.Body; // read message
Regex rx = new Regex(@"(d{6}?)",RegexOptions.IgnoreCase);
MatchCollection matches = rx.Matches(msg.Subject);
if(matches.Count > 0) caseCode=matches[0].Value;
kasbook = Regex.IsMatch(msg.Subject,@"(kas)",RegexOptions.IgnoreCase);
if (msg.Attachments == null) continue;
Why I am not able to read the body of the mail.
How can we consume a web service using asp.net out put in json formate?
View 1 RepliesI try to use the jquery + json to get all elements in form and build a JSON var to post in a ASP.NET MVC method.
[Code]....
It method get all fields in a form and build a JSON, but it dont put JSON inside JSON.
Example:
If i have the follow form:
<input name="person.name"><input name="person.age"><input name="person.address.street">
The serialized string build a JSON like this
{ "person.name": "??", "person.age": "??", "person.address.street": "??" }
I need a plugin or some function to generate like this:
{ "person": { "name" : "??", "age" : "??", "address":{ "street": "??" } } }
I have following code:
Code:
oStream = myCrystalReport1.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(oStream.ToArray())
Response.End()
That displays a crystal report in .pdf format. I works great except for follwing:
If I run the application from the web server I see an "envelope" icon on my .pdf screen which allows me to email the report. Another user, running the same application, does not see the "envelope" icon and there are no options to email.
I send a date parameter (@fdt and @Tdt) like "DD/MM/YYYY" format through Sql reporting servicesy query is select * from deposits where Depdate >= @fdt and Depdate <=@tdtin the aove query there is no record has been fetcheBut i give like this, Inthis case i get a resultselect * from deposits where Depdate >= '2010/04/01' and Depdate <= '2010/08/31'
View 5 RepliesI m just wondering is there any setting in sql server 2005 to change date format . I want to change it from US date format to normal one....i have seen some examples of changing it in while fetching data but than i have to change it for all sqldatasource strings...i m using sql server 2008 r2 but my hosting provider got sql server 2005
View 2 Repliesi have a string like "13-9-10" i want to insert this as date into sql server 2005 in to a coumn "custdate" as type as datetime i added a sql paramater like this
Private Sub demoinsert(ByVal arr_data() As String)
DbCmd.CommandText = "INSERT INTO TBL_enqloan(cusdate) VALUES(@cusdate,)"
With DbCmd.Parameters
.Add("", SqlDbType.Date).Value=Convert.ToDateTime("arr(0).tostring")
end sub
getting an convert error how can i do it?
I know this is probably a pretty easy thing to do and it is if I can upload the file and store it onto the hard drive of the server. What I need to do is read the text file into memory and then parse through it one line at a time. Anyone have any code that demonstrates that?
View 8 RepliesI have a text file named gisQuery129.json that is created using Json.NET - [URL] There is an example on how to create a JSON file and I have done that successfully, but I want to read the file on a page load event and add the values to .NET textbox controls for input values in a query. The created file looks like the following:
{
"myData": {
"randomNumber": "129",
"Application": "MyMapApp",
"FeatureId": "ALL",
"Feature": "ALL",
"spatialQuery": "FEATURE_ID= '11111' AND REQ_SEQ_NUM= 1 AND RAND_PARAM= 129 OR FEATURE_ID= '22222' AND REQ_SEQ_NUM= 2 AND RAND_PARAM= 129"
}
}
I want to read the data in the above sample JSON data and then populate my textboxes something like this:
txtRandParam.text = "129"
txtApplication.text = "MyMapApp" and three more text boxes after that.