|
|
HI,
I need to append new tags to the existing xml document.
PLease review this code ,
string txt = TextBox1.Text.ToString();
XmlDocument doc= new XmlDocument();
doc.LoadXml(txt);
XmlElement el = doc.CreateElement("property1");
el.SetAttribute("name1", "C1");
el.InnerText = "This row is being appended to the end of the document.";
doc.DocumentElement.AppendChild(el);
doc.Save(txt);
This code will be helpful to create the childnode, but iam looking for appending Root node as well as childnodes.
Please help me to extend this code for Root nodes.
Note : no need to create XmlDeclaration statement becoz it will be thr for selected xml file by default.
Appreciate your precious reply.
Thanks a lot,
Anjali...
|
|
|
|
|
mayuri123 wrote: but iam looking for appending Root node
XmlElement eRoot = doc.CreateElement("Root");<br />
doc.AppendChild( eRoot);
Keep in mind you can only have one root element
led mike
|
|
|
|
|
led mike wrote: Keep in mind you can only have one root element
Only if you want it to be valid
only two letters away from being an asset
|
|
|
|
|
Hi all,
String.replace("\","\\") never work for me.I am also try use char,but still no work. Can anyone help me on this?
regards
cocoon
|
|
|
|
|
Does this work?
String.replace("\\","\\\\")
|
|
|
|
|
The backslash in a string is used as an escape character and won't get printed on its own. To print a backslash, the string would be "\\". Another example of common usage of \ would be "\n" to perform a new line.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
String.replace(@"\",@"\\")
SkyWalker
|
|
|
|
|
Hi ,
Thanks for fast reply. Yes, string.replace("\\","\\\\") and string.replace(@"\",@"\\") are work great,thanks guy!
|
|
|
|
|
Hi,
i am currently taking part in a project at my university and making my first advanced steps in programming in C# and .NET. In my group we want to implement a sound module to manipulate the mic input. Due to our low level of experience we have several problems. Currently we can just load a wav-File into a buffer, adding a custom sample effect und play it back, all using DirectSound.
In theory, we want to be able to load the continous microphone input into a buffer to manipulate it in "real time" and then give the modified stream out of the buffer back through the speaker. I am sure there will always be a short delay, put hopefully it can not be recognized.
Most of the audio examples cover a recording of a mircrophone input into a wav-File. My intention is not to ask for the implementation of our project, but I hope you can give us some hints how we should begin and which functions are essential for our functionality.
We currently use C# with the latest .NET Framework (3.5) and DirectSound.
I am looking forward to a good excited discussion.
Sincerly,
Daniel
|
|
|
|
|
I am storing an object in one of the cell's tag in my dataGridView. As soon as I click on one of the column headings (to sort the grid) the object stored in the tag is deleted (tag is null). I have not overridden the sort functionality for the grid, it is just the default sort. Any ideas as to why the object stored in the tag is being deleted/nulled out? My data grid does have a binding source/datasource so not sure if that has anything to do with it.
Any help/ideas would be appreciated
Thanks!
|
|
|
|
|
hi
i want to get customers data from database as CustomerCollection class (strongly typed), and bind my dataGridView to my CustomerCollection object.
i defined Customer class as follow :
class Customer<br />
{<br />
private string customerID;<br />
private string companyName;<br />
<br />
public string CustomerID<br />
{<br />
get { return customerID; }<br />
set { customerID = value; }<br />
} <br />
<br />
public string CompanyName<br />
{<br />
get { return companyName; }<br />
set { companyName = value; }<br />
}<br />
<br />
public Customer() { }<br />
<br />
public Customer(string custID, string company)<br />
{<br />
this.CustomerID = custID;<br />
this.CompanyName = company;<br />
}<br />
<br />
public DataTable GetCustomers()<br />
{<br />
DataAccess da = new DataAccess("Data Source=.;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=1");<br />
DataTable dt = new DataTable();<br />
da.ExecuteCommand(new SqlCommand("SELECT CustomerID,CompanyName FROM CUSTOMERS"),out dt); <br />
return dt;<br />
} <br />
}
and defined CustomerCollection class as follow :
class CustomerCollection : System.Collections.CollectionBase<br />
{<br />
public CustomerCollection()<br />
{<br />
<br />
}<br />
<br />
public void Add(Customer customer)<br />
{<br />
List.Add(customer);<br />
}<br />
<br />
public void Remove(Customer customer)<br />
{<br />
List.Remove(customer);<br />
}<br />
<br />
public Customer this[int index]<br />
{<br />
get<br />
{<br />
return (Customer)List[index];<br />
}<br />
<br />
set<br />
{<br />
base.List[index] = value;<br />
}<br />
}<br />
}
but i don't know when i use this code :
Customer c = new Customer();<br />
this.dataGridView1.DataSource = c.GetCustomers();
how to bind my datagridView to my strongly typed collection object (CustomerCollection), how to do ?
thanks
|
|
|
|
|
Well, have you considered calling DataBind? That'll do it.
|
|
|
|
|
thanks for reply
when i use this code :
Customer c = new Customer();<br />
this.dataGridView1.DataSource = (CustomerCollection)c.GetCustomers();
the following error has shown me :
Cannot convert type 'System.Data.DataTable' to '_LayerSample.CustomerCollection'
|
|
|
|
|
Don't return a DataTable from your GetCustomers method. You need to return your List<customercollection> so you can databind to that.
So you need to change your GetCustomers to fetch the data from the database and use a datareader. iterate the datareader and create a new Customer class for each dataitem in the reader and fill the appropriate properties. Before your next iteration, add that Customer class to the collection with your Add method. Rinse and Repeat.
|
|
|
|
|
So you need to change your GetCustomers to fetch the data from the database and use a datareader. iterate the datareader and create a new Customer class for each dataitem in the reader and fill the appropriate properties. Before your next iteration, add that Customer class to the collection with your Add method. Rinse and Repeat.
thanks for reply
i know this way to get data strongly typed, is there any other way to get data strongly typed ?
however many thanks
regards.
|
|
|
|
|
I have an SqlConnection, what i need is to get the server value and the database value from the connectionstring it contains.
Is there an easy way to get these values, or do I have to resort to using the dreadful regexp?
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
|
|
|
|
|
Nvm, solved it ^^
SqlConnectionStringBuilder connstr = new SqlConnectionStringBuilder(ConnectionString);
string server = (string) connstr["server"];
string database = (string)connstr["database"];
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
|
|
|
|
|
Dear All,
I am a novice c# programmer, I am astounding seeing following code block
<br />
<br />
public class NewClass<br />
{<br />
public static NewClass Add(parm1,parm2)<br />
{<br />
NewClass newclass = new NewClass();<br />
return newclass; <br />
}<br />
}<br />
<br />
<br />
I want to what logic behind this return type(as class)
What it actually returns? what type is this, I am unware of this.. Any help highly accepted.
|
|
|
|
|
You need to buy a beginners book and work through it for the basics.
You can return any type you like, including types you define.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Can we use the DataAdapter method like
if(dAdapter.Upadate(dt) == 1)
MessageBox.Show("Update successful");
->Is Update method alwaya return 1 on successful update ?
->Is this is correct way to use the information that data has been updated?
-> If no, then what can be the possible consequencies ?
Your comments are welcome
|
|
|
|
|
Gee golly gosh, they do have a habbit of hiding this stuff in the documentation[^]
[quote]
Return Value
Type: System..::.Int32
The number of rows successfully updated from the DataTable.
[/quote]
|
|
|
|
|
Hello,
I am searching for a professional windows forms thumbnail component that will display images with the look and feel of the Windows Vista pictures folders or something similar.
Searching on the net I found many asp.net thumbnail components but nothing for windows forms.
Do you now any?
Thanks
|
|
|
|
|
can someone help me with how to calculate the variance and gradient of pixels contained in an image.
tony-yeyo
|
|
|
|
|
I guess you just want to access the pixels, as per my image processing articles, then build a list of how often each value occurs ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|