|
Member 578189 wrote: I need to insert a char in the beginning of the XML file. Char is “?”.
If you insert ? to the beginning of XML file, XML file will become invalid and you will not be able to parse it. Are you trying to add the <?xml version="1.0" encoding="utf-8" ?> line?
|
|
|
|
|
Navaneeth,
my original line is
and i need ?<xml version="1.0" encoding="utf-8">;
small background about what i am doing:
I am creating a xml file in console and trying it save it as XML.
And when i use this XML it gives me an error because char "?" is missing.
|
|
|
|
|
Member 578189 wrote: I am creating a xml file in console and trying it save it as XML.
Use the XML manupulation classes like XMLDocument . It has got a Save method which writes a XML file.
|
|
|
|
|
Dear All,
i am using DataRow for insert update query for records in c# and this error below what should i do?
Update requires a valid Insert Command when passed DataRow collection with new rows
what i have to do for insert record ?
Is this is good approach to insert and update data in tables.
Kindly brief me.
Sajjad Lashari
|
|
|
|
|
Sajjad Leo wrote: what i have to do for insert record ?
Follow the instructions in the error message. You need to create an Insert command on the SqlDataAdapter.
Sajjad Leo wrote: Is this is good approach to insert and update data in tables.
In my opinion? No, never.
|
|
|
|
|
Hi Dear,
You replayed good but i am still not able to get my goal,
can you guide me if i am inserting a record what steps should i follow please send me complete steps.
Sajjad
|
|
|
|
|
Sajjad Leo wrote: please send me complete steps
You have not sent me complete detail of what you are wanting inserted and where.
Basically, create a SqlConnection object, create a SqlCommand object, Open the connection, ExecuteNonQuery on the command object and then Close the connection.
Your command should preferably use stored procedures in the database.
|
|
|
|
|
Dear,
I solved that problem now i using a sql query for retrieving a record from a student table i am selecting class from drop down like Class A and then the data of class A name of students will display in list box and then i select one name of class A from list box and want to display data in grid view i am writing query like
string rec = "select * from student_biodata where student_name = '" + liststudent.Text + "' ";
But one problem is that if i am selecting name like 'a' then two record displayed in grid view like 'a' of class A and 'a' of Class B so what should i do please guide me correct query as i can get only one record.
Thanks
Sajjad Ali
modified on Tuesday, March 3, 2009 5:22 AM
|
|
|
|
|
What is the best method if I want to limit The number of connections a server accepts?
I suppose this is not really a good way to achieve what i want:
while(true)
{
if(numberOfConnections < 100)
{
Socket s = listenerSocket.Accept();
...
}
else
{
Thread.sleep(1);
}
}
Has anyone a better idea how to keep the cpu down?
|
|
|
|
|
I's probably use a ManualResetEvent instead of sleeping a thousand times per second - it's more accurate and less of a hack.
ManualResetEvent m = new ManualResetEvent(true);
while(true)
{
m.WaitOne();
if(numberOfConnections < 100)
{
Socket s = listenerSocket.Accept();
...
}
else
{
m.Reset();
}
}
And somewhere at a place where you close the connections, do m.Set() if the number of connections is lower than 100 again.
But beware, I just woke up, so don't trust this code or even this idea
|
|
|
|
|
Hi Harold,
harold aptroot wrote: sleeping a thousand times per second
you are an optimist then. You may be interested in my article on timers.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:59 AM
|
|
|
|
|
Lol yea I exaggerated - how about: Up to a thousand times per second but it will never be that much due to the bad timer resolution.
But the idea is the same.. sleeping "many" times per second isn't a good idea.
|
|
|
|
|
Hmm I think I'll have to be carefull with the m.Set()
but worth trying...
|
|
|
|
|
Use the asynchronous fashioned methods. Like BeginXXX() and EndXXX(). There is a Socket.BeginAccept[^] available.
|
|
|
|
|
I don't understand how that would spare the cpu
or would help me to get rid of Sleep(x) ;?
I just want my loop to block, so it won't accept any new connections
until the older ones are gone... without using any cpu time.
|
|
|
|
|
See MSDN[^] got a sample.
|
|
|
|
|
Hi,
invader82 wrote: Has anyone a better idea how to keep the cpu down?
Use an event-driven scheme if one is available: getting a signal something must be done, is more efficient than having a loop polling whether somethind should be done all the time. (BTW: Thread.Sleep(1) will take 10 or more msec on average, see my timers article).
If you can't use an event-driven scheme (because no event is available, or you don't trust it sufficiently), implement a polling loop, however give it a delay that fits with your needs, e.g. if the client is a human typing/clicking in a browser, 50 msec would be good enough.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:59 AM
|
|
|
|
|
I rather wanted something that would really block that loop until
the number of connections drops back below a certain value.
I'll try the ManualResetEvent that harold proposes...
I think it's a "cleaner" solution for the problem
than sleep()
|
|
|
|
|
Yes, ManualResetEvent supports one of several event-driven schemes .NET provides.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:00 AM
|
|
|
|
|
Hi,
I'll have to prepare a software in C# that using the software we can call from pc and receive call by pc. obviously a modem is connected with the pc.
I want some idea about this project. if possible then send me some sample code or url for reference..
Please help me...
Thanks
Rizvi.
|
|
|
|
|
rizvi_codeproject wrote: url for reference..
Oh, you should have said that right away.
Here: http://www.google.com/[^]
Kristian Sixhoej
"You can always become better." - Tiger Woods
[ My blog ]
|
|
|
|
|
hi,i'm trying to get the details of each process in c# but some of its attributes didnt return anything, (i made object of class Process --> p):
1) p.ExitTime;
the ERROR: process was not started by this object
2) p.startInfo.WorkingDirectory;
but it didnt return the directory of the process,just a empty string
3) p.username;
empty string, i searched the net and tried many codes but nothing helped me ,they all return the usename of the computer, i want something like task manager's username:system, local service ....
And one more thing :how does taskmanager calculate cpu usage?
|
|
|
|
|
Hi,
the MSDN documentation on the Process class includes this paragraph, it may be relevant to you:
"The process component obtains information about a group of properties all at once. After the Process component has obtained information about one member of any group, it will cache the values for the other properties in that group and not obtain new information about the other members of the group until you call the Refresh method. Therefore, a property value is not guaranteed to be any newer than the last call to the Refresh method. The group breakdowns are operating-system dependent."
shefa' isied wrote: how does taskmanager calculate cpu usage?
the Microsoft guy who wrote Task Manager is good friends with the Microsoft guy who wrote the scheduler, so he is allowed a peek in some system tables we mortals are not supposed to access.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:01 AM
|
|
|
|
|
Hi
I would like to drag my contact(in icon view) to any location point by mouse. The behavior is same as icon view, without auto arrange and without align to grid in window explorer. I found all drag and drop example use index to represent location and the drop is to nearest location(by index).
Anyone know how to implement it?
Thanks first.
Regards,
PeiYang
|
|
|
|
|
As no-one has answered your question, I'll have a go.
Take a look at Control.MousePosition and see if that helps you.
Good Luck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|