|
|
Hi everyone.
Yesterday I started a thread and was grateful to have received such knowledgable responses. It was great! I ended that thread in saying that today would be a journey in that I had to now feed elements of my XML(converted from a .csv) document into a datagrid in order to display data in a very clear way.
I converted the csv using the XMLWriter class and now know that I must use the XMLReader class to read this data but I do not know how to get a step further. In otherwords, I am not sure how to read the elements and put them in the datagrid.
Any help would be greatly appreciated
Thank you
Skylo
P.S. Does anyone use and/or have an opinion of the open source datagrid that one can download on this site?
...one of the main causes of the fall of the Roman Empire was that,
lacking zero,
they had no way to indicate successful termination of their C programs.
-Robert Firth-
|
|
|
|
|
You don't need to use an XmlReader to display your data in a DataGrid . You can use the ReadXml method of DataSet and then assign that DataSet to be the data source of the grid in question.
DataSet ds = new DataSet();
ds.ReadXml(@"C:\MyXmlFile.xml");
MyDataGrid.SetDataBinding(ds, "MyTable"); Apply a DataGridTableStyle to gain more control over how the data is displayed.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hello,
After you edit a XmlNodelist in c#, is it possible to "paste" the XmlNodeList into another file that has the same structure? (so a node is being replaced by the one that was edited)
Thx
e.g.
I want this xml-node int the xml-file, and replace the 'old' node
<authors s="male">
<id>172-32-1176</id>
<lname>Black</lname>
</authors>
<AuthorsTable>
<authors s="male">
<id>172-32-1176</id>
<lname>White</lname>
</authors>
<authors s="female">
<id>213-46-8915</id>
<lname>Green</lname>
</authors>
</AuthorsTable>
|
|
|
|
|
Replace one node's InnerXml with to other node's InnerXml...
|
|
|
|
|
Replace one node's InnerXml with the other node's InnerXml...
|
|
|
|
|
Deal all,
I have a problem that I have to load a huge amount of data into the SQL server it is about a million record from some binary files, in this case I have to ways to do it, the first one is use the old ADO library any load it by using record set the speed here is acceptable, but in the second ay I would like to use ADO.Net I have to fill that data into a dataset and to use SQLDataAdaptor to update my database which will take very long time. So if any body knows a faster way for that by using ADO.Net libraries
Regrads
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Insread of loading your data into DataSet , use SqlDataReader to read records. Also create stored procedure and use SqlCommand class to run them from your application. This will very better performance than using DataSet for large number of datas.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
You parameterized queries for batch updates, like so (assumes insert only, such as for a data wharehouse):
SqlConnection conn = new SqlConnection("...");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO MyTable (Field1, Field2, Field3) " +
"VALUES(@Field1, @Field2, @Field3)";
SqlParameter param1 = cmd.Parameters.Add("@Field1", SqlDbType.BitInt);
SqlParameter param2 = cmd.Parameters.Add("@Field2", SqlDbType.NVarChar, 40);
SqlParameter param3 = cmd.Parameters.Add("@Field3", SqlDbType.NVarChar, 40);
using (conn)
{
conn.Open();
while (true)
{
string line = read next line from data file;
string[] fields = line.Split(',');
int id = Convert.ToInt32(fields[0]);
param1.Value = id;
param2.Value = fields[1];
param2.Value = fields[2];
cmd.ExecuteNonQuery();
}
} This should give you some idea of what to do. Also, don't use stored procs like Mazdak mentioned. There is a performance penalty when using simple statements like this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear Heath,
Thanks for help, i think that this is a traditional way to solve the problem it has a problem: when you try to load this amount of data without closing the data connection you should expand the log file of the sql server to be about 512 MB else will get an erreor message which tell you that sql server could not save transaction data,
and if we don't like to open and close the connection we should open a transaction and commit it evry data block.
i have an other idea: if we can devide that data to some blocks then i will pass evry block to a thread which will insert it into the data base with a new connection ... it is an idea i did not try it but i will and i think it will enhance the application performance
Regards
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Perhaps, but this isn't the SQL forum.
If youre application doesn't need to do this as part of some more complex functions (i.e., you just need to do it internally from time to time), you should actually check out the bcp utility that ships with SQL Server, or use the BULK INSERT SQL statement (which I see no reason why it couldn't be used with ADO.NET to execute it) which does all this work for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You may want to look into Sql Server's Bulk copy functionality to do your inserts.
|
|
|
|
|
You may want to take a look at using SQL Server's Data Transformation Services(DTS) to perform the load. From your short description, it sounds like the kind of problem that DTS was made for.
Using an ActiveX task, you could make use of a COM-registered .NET assembly (or traditional COM object) to perform any advanced transformations needed on the binary source. Also, if this is a recurring task, DTS packages integrate nicely with SQL Server's job scheduler.
Hope that helps.
--Jesse
|
|
|
|
|
Dear Sir,
Thank you for your help, but i am searching for a solution which depend only on .net technology without using COM technology
regards
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
I have created a control based on the TextBox control, and would appreciate if someone could tell me how I can get the background to be painted with a brush using the HatchStyle and HatchStyle.OutlinedDiamond. The OnBackGround(...) and OnPaid (...) events don't seem to get fired off. I want to only have the background drawn with the HatchStyle.OutlinedDiamond as design time, and to have the normal background at runtime.
|
|
|
|
|
Easy, you cant! You will have to write one from scratch.
top secret
|
|
|
|
|
I want to close resource used by the web cam it gives error when i open the camara.......
|
|
|
|
|
Details! Lots more details!
Which webcam?
What are you using to communication with the webcam?
Are you using API calls and which ones?
Are you using WIA? The manufacturer's SDK?...
Code snippets of what your doing also help GREATLY!
RageInTheMachine9532
|
|
|
|
|
Hello,
If i have a simple Xml-file like this:
<test nummer="1">
<school name="handel">
<director> guy</director>
<teur> qui</teur>
</school>
<school name="bedrijf">
<director> louis</director>
<teur> qyu</teur>
</school>
</test>
How can i get the attributes "handel" en "bedrijf" in a textbox?
thx in advance
|
|
|
|
|
Use XPathDocument class. Search for it in google or this site for examples.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
Have a look at the XPath tutorial at www.zvon.org. The XPath for attributes uses the @ symbol, so the XPath to get the school name attributes is: /test/school@name.
Using this in .NET (C#):
XmlDocument test = new XmlDocument();
test.LoadXml(pathToXmlFile);
// to get just the first (or a school at any position) school name, use [position] in the XPath
TextBox.Text = test.SelectSingleNode("/test/school[1]@name").InnerText;
// to get all school names
XmlNodeList list = test.SelectNodes("/test/school@name");
foreach(XmlNode node in list)
{
// process nodes here....
}
|
|
|
|
|
I have a custom component i am using in my project. It's base is entirely covered with panels and other components. When i click on it, it is the child component that is activated rather than the base component.
Is there any way to determine when a child of the base component is activated via the base component? I know it could be done with an event for each of the child components that check a variable on the base component. But i'm looking for a simpler way that fires a single event for gotfocus and leavefocus.
Note: I'm trying to make this component entirely self contained, so i'd like to implement this inside the component, rather than the parent form.
Cheers
Cata
|
|
|
|
|
The Catalyst wrote:
Is there any way to determine when a child of the base component is activated via the base component?
You mean container? "base" component is something entirely different, i.e. the base class of a derivative class.
Only one control can have focus at a time. This is universal in all window managers. Container controls can, however, receive notification messages from their child controls, although you may have a problem if you're using containers within containers.
Your container control should extend from ContainerControl , or most often one of its derivatives, UserControl . Other controls can handle the following as well, though, so long as they're parent to controls for which you want to receive messages. Again, this is rooted in Win32, so experience with Win32 programming is beneficial.
Just override the WndProc of your container. You'll get notification messages for most child control notification messages as well, so you'll need to distinguish between the handles using the Message.HWnd . You can always get a control from it's handle using the static Control.FromHandle method, too.
Keep the message handling efficient and be sure to call base.WndProc with the reference to the Message struct passed to you when done, otherwise messages won't be dispatched to their destination windows (controls) and nothing will work inside of that container.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm trying to set a control up so that it has rounded corners like a windows form. I have enabled opaqueness, and create a bitmap with alpha textures in the corner possitions. However, the components behind the current instance do not show up, instead I am left with the corners displaying the containers background.
I know that the documentation for ControlStyles says:
Note: If there is another control between the control and its parent, the current control will not show the control in the middle.
Does anyone know of a way around this? Would it be possible to blend a controls image onto the background texture when it is moved?
Cata
|
|
|
|
|
If you want to apply Visual Styles to a button like that which is applied to forms in Windows XP and newer, then P/Invoke and use the Theme API, which is documented on MSDN (lookup OpenThemeData ).
If you're looking for information about how to owner-draw atypical buttons, search CodeProject for many examples (including a pretty decent one for Aqua buttons, or those used in Mac OSX).
Microsoft MVP, Visual C#
My Articles
|
|
|
|