How do I display XML data in SQL in HTML - c#

I am working on redesigning an old application that stored content in sql as xml data. I know that if I have a file I can use this to display the data in HTML:
xmlhttp.open("GET","xmlfile.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
Now, lets say I have a table in SQL. In a column I have the contents of "xmlfile.xml". How can I go about displaying that data?

Are you looking for specific field in the xml, SQL Server can query fields of a xml tag inside a sql server column row.
http://msdn.microsoft.com/en-us/library/ms345122(v=sql.90).aspx

Related

Retrieve xml elements from sql server

I have xml stored in a sqlserver table column type as varchar. I need few elements from that xml string. Is there a way I can process this xml and store its elements in a table and retrieve when ever I need.

How to import html data to MySql

I have HTML source and want to import specific tags from the HTML source to database-table " MySql " by using C#.
any suggestion would be great.
Your question is very abroad and we need some enlightment on your question, first off:
Do you have a database yet?
Do you have a connection with that database?
Have you set up a way to fire queries at that database?
Have you created a user that is allowed to fire queries at the database?
Why not save every unique column as a column in the database? pasting plain HTML into a database isn't really good practise.
Create a table named test_table with the column ID with an auto increment and a column data with the type longtext.
for the query:
INSERT INTO `test_table` (`data`) VALUES ('<a>someHTML code</a>')

Store DataTable to SQL Server column

I'm trying to store a DataTable into a single column in a SQL Server table. The idea behind this is a user runs a SQL command and the returned output is stored into a datatable, then I want that datatable to be stored into a SQL Server logging table. Later on I want to be able to retrieve that entire datatable back for displaying on a logging aspx page.
Currently I'm just storing it as a big string but that doesn't give me column headers and the formatting is kinda funky as well as being inefficient.
TIA
I would probably convert the datatable to XML and store it into an XML field type if I was going to do what you are trying to do.
Hello you can try with WriteXml
this link give you sample interessant : http://msdn.microsoft.com/fr-fr/library/system.data.datatable.writexml.aspx
Another Idea is to create two tables in your database. It is slightly complex.
One Table contains two columns, Let name the table PTable.
Columns:
ID and ColumnID
ID is the primary key and ColumnID contains the name of your column in datatable
After creating this table create another table. It will consists of three fields. Let name it STable. This table stores the columns of you datatable.
Columns:
stblID, PtblID and PtColumnID
StbID is the primary key in this table, PtblID is the Primary key of PTable and PtColumnID is the ColumnID of PTable. This table stores the rows of table. Now store the data in this table and receive the data when you need it.
and the simplest idea is to create a table in your datbabase having an xml column and store your datatable as an xml.

Reading a XML file from SQL Server in ASP.NET

An XML file was saved into a SQL Server database with the following code:
USE XML
GO
INSERT ENTERTAINMENT (content)
SELECT * FROM
OPENROWSET(bulk 'c:\entertainment-jist.xml', single_blob ) AS X
The file was saved in a column with an xml datatype.
How can the whole content of this file be read in an asp.net page using C#?
You can use SqlDataReader.GetSqlXml to read the XML field.

How to build Query dynamically using asp.net3.5 and c#.net

i need create query dynamically in my .cs page. Actually what happens in my application is user can pass the column name and Table names from the page. by using those parameters(columns and tables) we need build Select query . we need retrieve those values from database and show in text format to user.there may multiple table and single table have multiple columns also.
please try yo help how to do this ny using asp.net3.5 and c3.net
So you need to have a dynamic query that populates its columns as per users requirement. It is not achievable but I have a nearby solution of it.
You can specify from which tables you want data and then using system functions create dynamic query of yours and get it done.
If nothing else, just create the query string dynamically and then pass it to the ADO.NET routines.
string qry = String.Format("SELECT {0} FROM Table", colName);

Categories

Resources