using SQL SERVER can create xml Document like [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
IN SQL SERVER can create XML Document like following format with every column name come with Datafield FieldName="Batch"
CID,BATCH,EXP_DATE are column names.
enter image description here

Try something like
SELECT 'BATCH' AS [DataField/#fieldName]
,BATCH AS [DataField]
,''
,'EXP_DATE' AS [DataField/#fieldName]
,EXP_Date AS [DataField]
FROM SomeWhere
FOR XML PATH('Memory');
The empty string in the middle is needed to start a new element
And be aware, that the dateformat will be ISO8601 and not 190615 (you should be happy about this!)

If you want to achieve XML document creation from C#, then it can be achieved through ADO.net with Help of DataSet. Method name is DataSet.WriteXml(string Filename).

Related

Returning a list of objects from a function to a text file C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a big function that returns a list of objects. I basically need the results to be put in to a text file. The list contains objects of a class with attributes string Index and integer count. I would want it to be written in a textfile like:
Index : Count fe.
BOOK_FROM_STORE : 27
Anybody has some guidance?
Parse the data held by your object to string and then write it to a text file.

How to align content from a lump of data from sql to web? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a text in SQL like: "I want to eat. I'm hungry."
I use ASP.NET MVC to get data from database:
#Model.content
#Model.content is "I want to eat. I'm hungry."
I want to format text to display, for example, it might come down the line:
I want to eat.
I'm hungry.
Since, you don't prefer saving "\n" in the database, you can just split the entire into an array and loop through each item to display it with breaks. use Split
Something like:
#foreach (var item in Model.content.Split(".")) { #item <br /> }

C# how to get diagram name of element - Enterprise Architect [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I need to get diagram`s name of specific elements. Is it possible ?
I added elements note with specific stereotypu using profile to EA project. Then i want create a plugin where i find this notes and diagram names where they are located. (i want export notes and diagram names to excel)....PS: Sorry for my bad english
Issue a SQL like
Repository.SQLQuery("SELECT t_diagram.name FROM t_diagramobjects AS dobj INNER JOIN t_diagram ON dobj.diagram_id = t_diagram.diagram_id WHERE t_diagramobjects.Object_ID = <elementID>"
Just replace <elementID> with the element's elementID. You could alternatively retrieve the diagram GUID (t_diagram.ea_guid') and get the diagram details viaRepostory.GetDiagramByGUID`.

How c# asp.net read by separate between xml and string in xml node? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I got result from some system and don't know how to read by separate btw xml and string as below example.
<result>
<xmldataHeader>
<HeaderId>1</HeaderId>
<xmldataDetail>
<DetailId>1</DetailId>
<DetailName>test</DetailName>
</xmldataDetail>
</xmldataHeader>success
</result>
expected result, it can read "success" or only xml in <result></result>
Thanks in advance.
If your XML structure remains almost static as given in this question, you will be able to access the "success" text with doc.SelectSingleNode("result").LastChild.OuterXml);Please find the sample code below.
XmlDocument doc = new XmlDocument();
doc.LoadXml($#"
<result>
<xmldataHeader>
<HeaderId> 1 </HeaderId>
<xmldataDetail>
<DetailId> 1 </DetailId>
<DetailName> test </DetailName>
</xmldataDetail>
</xmldataHeader> success
</result>");
Console.WriteLine("Succes :" + doc.SelectSingleNode("result").LastChild.OuterXml);
Console.WriteLine("xmldataHeader :"+doc.SelectSingleNode("result").FirstChild.OuterXml);
I dont totally understand your question. But if you want to separate all tags and get the individual data, you'll have to parse the xml.
One example is by using XmlReader in C#.
https://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx

Error -input string was not in a correct format [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I don't understand what is wrong i did the same code with the insert and run well
Entity obj = new Entity();
.
.
.
obj.DEPID = decimal.Parse(((TextBox)GridView1.FooterRow.FindControl("txtDEPID")).Text);
myFactory.UpdateObject(obj);
The value that is returned by the
((TextBox)GridView1.FooterRow.FindControl("txtDEPID")).Text
Is not a decimal-like string. It contains some other Special Characters like alphabets etc.
While passing the values, you need to make sure that the values being passed match the values required. Check what is the value of this.
txtDEPID.Text;
Use it in a MessageBox, to check for the value. I'm sure there is some sort of non decimal part in the string. Which is causing the trouble while converting the String to Decimal.
MessageBox.Show(txtDEPID.Text);

Categories