|
Open the connection
Niladri Biswas
|
|
|
|
|
Dear All,
I have following xml which i want to convert it into DataTable, but it doesent reports any record
the xml file contents
<DownloadedForms>
<row>
<CommunityCode>28-2801-0001</CommunityCode>
<FormName>Form6</FormName>
<FormPage>1</FormPage>
<FormPath>c:\PDF Files\BAMYAN\Bamyan\28-2801-0001\Form6\28-2801-0001-F6.pdf</FormPath>
<isVerified>2</isVerified>
<RejectionReason>The Form is Scanned in low Quality</RejectionReason>
<Id>6</Id>
<ProvinceID>28</ProvinceID>
</row>
</DownloadedForms>
and the code to read the xml file is
XmlTextReader read=new XmlTextReader("xmltopic.xml");
while (read.Read()) {
}
DataTable dt=new DataTable();
dt.ReadXml(read);
MessageBox.Show(dt.Rows.Count.ToString());
how can i convert that xml into dataTable?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Try
DataSet ds = new DataSet();
ds.ReadXml("FileName");
himanshu
|
|
|
|
|
Yes its working!!
go ahead with Himanshu code

|
|
|
|
|
|
do some googling
you will get it
|
|
|
|
|
Please, don't delete your messages. It's not helpful to other people who are searching for an answer to a related question
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I am really sorry, In fact i was trying to response for "himunshu1256", but i dont know y the respone was automoated to "savetiger".
I had responed to "himunshu1256" two times, but in both the message was redirected to "savetigers"
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Creating DataTable from XML DataTable
DataTable mytab = new DataTable();
mytab.ReadXml("c:\\myfile.xml");
To Read your XML file U have read it to a Dataset.
like
Dataset myds = new Dataset ();
myds.ReadXml("c:\\tt.xml");
Get your table from
myds.Tables[0].Rows.Count
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
I wrote a program to download .jar file to mobile ,but its is saving as .aspx file to mobile and it is reporting an error like this file is not supported by the device.But there is no problem with windows mobiles..
Please Help me to find out the solution for this.
Code Snippet I used to download as follows
protected void Command1_Click(object sender, EventArgs e)
{
string EXEPath = System.Configuration.ConfigurationManager.AppSettings["downloadEXEPath"].ToString();
string exefilename = System.Configuration.ConfigurationManager.AppSettings["EXEFileName"].ToString();
HttpRequest httpreq = Context.Request;
HttpResponse httpres = Context.Response;
FileInfo fil = new FileInfo(Server.MapPath("~\\" + EXEPath));
if (fil.Exists == true)
{
httpres.Clear();
httpres.ContentType = "application/java-archive jar";
httpres.AddHeader("Content-Length", fil.Length.ToString());
httpres.AddHeader("content-disposition", "attachment; filename=" + exefilename);
httpres.BinaryWrite(File.ReadAllBytes(Server.MapPath("~\\" + EXEPath)));
httpres.Flush();
httpres.End();
}
}
|
|
|
|
|
hi again , is there any way to dock a windows forum to the bottom right hand corner ?
Above the taskbar and to the right hand side of the screen ?
Thanks
modified on Wednesday, June 24, 2009 9:51 PM
|
|
|
|
|
Do you mean a form ?
There is nothing built in to do this, but you can write code to find out the size of the main screen, position it where you want, and handle the event when the form is moved, and move it back.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
this may give you some ideas[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a WinForm with a DropDownList and DataGridView. I need to display the States based on the Country selected.
This is my Code:
private void cbCountry_SelectedIndexChanged(object sender, EventArgs e)
{
if (loading == false)
{
CountryId = (int.Parse(cbCountry.SelectedValue.ToString()));
this.dsWBGT = dataComm.GetStateByCountryId(CountryId);
dgvState.DataSource = this.dsWBGT;
}
}
When I step through the app everything works and the dataset gets the correct info but the DataGridView only display (Collection)
Can someone tell me what am I doing wrong?
I am populating the combobox with the following code:
private void PopulateCountries()
{
DataSet dsCountries = dataComm.GetCountries();
cbCountry.DataSource = dsCountries.Tables["Country"].DefaultView;
cbCountry.DisplayMember = "Country";
cbCountry.ValueMember = "Id";
}
Illegal Operation
|
|
|
|
|
Nevermind I found the problem...
Illegal Operation
|
|
|
|
|
|
Instead of referencing the datagridview (dgvState.DataSource = this.DataSet) I used the bindingsource (bindingSource.DataSource = this.DataSet).
Illegal Operation
|
|
|
|
|
In JavaScript you can run document.getElementsByTagName ("img") to get all of the image tags. Can you do something similar in C#?
Also you can do this is JavaScript:
var image = document.createElement ("img");
image.getAttribute ("src");
Again can you do something similar in C#? And if so, how?
This is how I'm getting the webpage: http://www.tech-recipes.com/rx/1954/get_web_page_contents_in_code_with_csharp/[^]
Thanks.
|
|
|
|
|
If it's really XHTML and not just plain old HTML, you could just treat it as xml: use XmlDocument and its SelectNodes(string xpath) function
At least, that's what I would do..
The xpath would be something like "//img/@src" I think (if you want all src attributes of all img's as your code seems to do)
|
|
|
|
|
Okay I'll give that a try.
I've found out that the XHTML isn't completely valid. Some of the tags aren't closed properly. Here's in excerpt:
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<meta name="robots" content="noarchive"/>
<meta name="description" content="/a/ is 4chan's imageboard dedicated to the discussion of Japanese anime and manga."/>
<meta name="keywords" content="imageboard,japan,anime,manga"/><link rel="alternate stylesheet" type="text/css" href="http://zip.4chan.org/yotsuba.9.css" title="Yotsuba"><link rel="stylesheet" type="text/css" href="http://zip.4chan.org/yotsublue.9.css" title="Yotsuba B"><link rel="alternate stylesheet" type="text/css" href="http://zip.4chan.org/futaba.9.css" title="Futaba"><link rel="alternate stylesheet" type="text/css" href="http://zip.4chan.org/burichan.9.css" title="Burichan"><link rel="alternate" title="RSS feed" href="/a/index.rss" type="application/rss+xml" /><title>/a/ - Animu & Mango</title>
While some of the tags are somewhat formed properly, some aren't. The first one is easy:
result.Replace ("\"/>", "\" />");
I think I could use regex for the tags missing a closing "/" but I don't know how to do that.
[Edit]
Okay the result.Replace bit isn't working.
modified on Thursday, June 25, 2009 1:18 PM
|
|
|
|
|
I'm afraid you may have to use a custom parser, for HTML.. That will work, but it's a lot of work to make.
|
|
|
|
|
Well all of the HTML seems to be properly nested as per the XHTML specs, but some of the tags simply aren't closed properly. All I may need to do is C#'s version of PHP's preg_replace function.
|
|
|
|
|
If you can get that to work then it's probably less work, but it may not be as robust. Up to you though
|
|
|
|
|
I found more malformed HTML on other boards. It seems that my program will be significantly more complicated than I though.
Putting a XHTML transitional doctype creates 431 errors just on one thread alone.
|
|
|
|
|
I have a MDI project. The child forms have a menustrip, the menustrip used to have items like File, Edit etc. But today when I opened the project the items where gone from designer view. I can still find the items in the dropbox that contain all objects on the form, but when I select them they do not appear. It is not the allow merge property the most people think it is, this is in design mode not run time. The menu doesn't even appear at run time. I have tried google and other sources no sucesss?
Anyone know what causes this ???
tom
|
|
|
|