|
Bernard, there are five threads involved. I emit the thread id into the trace file after the time stamp and it makes it a breeze to identify which thread is responsible for what message. It's very helpful.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Hi I have text as an output that is in the following format.
Example install cdb 000
Firstname LastNameNot Started(2) Normal02/09/2013 18:0002/09/2013 23:00426
Example install cdb 000
Firstname LastNameNot Started(2) Normal02/09/2013 18:0002/09/2013 23:00426
Example install cdb 000
Firstname LastNameNot Started(2) Normal02/09/2013 18:0002/09/2013 23:00426
Example install cdb 000
Firstname LastNameNot Started(2) Normal02/09/2013 18:0002/09/2013 23:00426
What im trying to do is to substring/split this text so i can put it in a datagrid or list view.
Idealy I need the text in the following format so I can do this but I am having trouble trying to figure out the c# behind this.
Ideally the text would output as,
Example install
cdb 000
Firstname LastName
Not Started
Example install
cdb 000
Firstname LastName
Not Started
etc, for each entry in the source text.
(2)Normal02/09/2013 18:0002/09/2013 23:00426 (remove this text from the string)
The problem is that I would have to loop through all the text from the source to get this output. But the source text above is not always that length and could contain more entries.
Any ideas on this one?
I would apreciate any help anyone can give.
Thanks
|
|
|
|
|
Probably the best way to parse this (you did't specify if there are seperators between fields!) would be a rather complex regular expression. This expression would have to take into account the possible values in certain columns, such as that "Not Started" column, to server as boundaries that the RegEx parser can use to find other fields, like first and last name.
|
|
|
|
|
Thanks dave,
And I didnt supply if there were seperators as the source text is the format it is supplied in.
Also the firstname/lastname is an example this would actually have someones name.
thanks
|
|
|
|
|
Member 10119837 wrote: And I didnt supply if there were seperators as the source text is the format it
is supplied in.
OK, then the answer doesn't change. If there is no seperator between fields and no distinct column width for each field, String.Split and String.SubString will not help you. RegEx is about the only way you're going to get this done.
Member 10119837 wrote: Also the firstname/lastname is an example this would actually have someones
name.
Says Mr. Obvious. What may not be so ovious is that some people go by one name and others go by more than two, so your going to have to make sure you test those possibilities.
|
|
|
|
|
I'm going to assume, based on what you describe, that you have no control over the "batch" of "entries" to be parsed here. Is that correct ?
The second issue is: to what extent is there any possible variation in the content of each "entry" you need to parse, and re-format ? As Dave pointed out to you, is it possible that the "name field" in each entry could vary, as in: Robert Smith; Robert T. Smith; Robert Thomas Smith; R. T. Smith III; Robert Smith 3rd. ... and so forth.
The extent to which you can establish the "variation" possible in the entries imho is going to determine the complexity of either:
1. creating a RegEx as Dave suggested.
2. taking your "batch" and transforming it into another "batch" in which you have inserted de-limiters so that you can, then, use string.Split.
I would likely write code to transform the original data (file, stream, whatever) and insert delimiters, simply because I am not expert in RegEx, and the C# code I'd write, imho, might be more maintainable, and re-usable. However, I would not doubt that someone like Dave could write a documented RegEx expression of great internal complexity that would be equally maintainable, and re-usable. So your choice may depend on what you are most expert in using now, and, given a need, for other people in the future to update, maintain, re-use, your code what those people are likely to be expert in.
Now, if the data was in XML format, you might be looking at defining an xsd to handle transformation.
good luck, Bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
if there are separators then you typical use split.
split on value, split on line count ,typical of csv file type.
Now, you also can have a file that is fixed length fields..
Split then on field count then you just substing(x,y) out and prob split on line feed.
Now, if your trying to sort data out of something that follows no standard then now your looking at some sort of parsing method.
either reg expressions or loops.
=)
|
|
|
|
|
One of our customers receives an error message while running our application and many other applications on their computers. The error message is in German: "Win32Exception (0x80004005): Fehler beim Erstellen des Fensterhandles" which likely corresponds to "Win32Exception (0x80004005): Error while creating window handle".
Now we are trying to find out how that is caused.
When searching the web, there is a lot of confusion about those "handles". When looking into Windows Task Manager: which column in the Processes tab does correspond to the "correct" type of "handles": "Handles", "User objects", "GDI objects", ... (found all of them)
Or better take Process Explorer, and look at which columns?
And: what's the limit of those handles (system-wide, per application, ...)? (Found numbers from 1000 for the application to 16 million for the system; Process Explorer shows currently some 47000 Handles system-wide on my PC...)
Thanks a lot for trying to help me get rid of the confusion.
|
|
|
|
|
The max number of handles has values as both pre-process and system-wide, depending on the version of Windows you're talking about and the conditions under which it is running. It's not exactly a straight forward answer. Read this[^] for more information.
Truthfully, if you're getting this message, you might want to look at the Task Manager Handles column on the affected machines, not yours. There are cases where software leaks resources and handles, exhausting the system handle pool and causing problems like this. Usually the culprit process will stand out prominently. It's very rare to see a process go over 10,000 handles.
I had a Dell OSI service leak handles years ago, showing over 100,000 handles in that one process alone, before causing Windows to lose it's mind generating all kinds of problems over every other process that was running.
|
|
|
|
|
Thanks for this information.
According to the link you provided, some 16 million handles are allowed, but allocating handles in handle pages may reduce the number.
So things are complicated to analyse: on the custumer's computer, an application used up some 22 thousand handles when our application crashed, but at a different crash that application was below 1000 handles... And even with 22000 handles: that's some 1.5% of available system resources, we will hardly be able to convince the manufacturer of that program that they do something terribly wrong thus causing our application to crash...
By the way, how can an existing window handle be lost? In one case, our application crashed at an Invoke: the window handle did no more exist. A dialog had been opened, a control with its own window handle had been used succesfully; then the user had a break, the computer was locked (session switch event); after unlocking an hour later, the user did something else on the computer before using our program again, and then it immediately crashed due to the missing handle. I do not understand that. We did not Dispose() of it.
And all those problems happen with one single customer only, hundreds other customers never experience such problems (and remote access is not possible here: everything top secret).
|
|
|
|
|
Bernhard Hiller wrote: how can an existing window handle be lost?
Open a handle to an object and never properly close it, then orphan it by letting the variable that was holding the handle fall out of scope.
In a .NET app, that's quite easily done by, say, creating a Graphics object and never calling Dispose on it when your done with. Or by allocating a Font, Brush, Pen, Stream, ... by no means an exhaustive list.
Bernhard Hiller wrote: In one case, our application crashed at an Invoke: the window handle did no more
exist. A dialog had been opened, a control with its own window handle had been
used succesfully; then the user had a break, the computer was locked (session
switch event); after unlocking an hour later, the user did something else on the
computer before using our program again, and then it immediately crashed due to
the missing handle. I do not understand that. We did not Dispose() of it.
I don't have a clue there. You'd have the find out what else is running on the machine, such as virus scanner, and see if you can replicate the problem outside of their environment.
|
|
|
|
|
Hi
i have two forms , first form has a datagrid to show Rows record of table and Second Form is the details of every record in dataGrid , when we double Click the row .
In the Second Form , I need to Update Records . So I check the record ("RegNo") is Duplicate for a specific Year.
Here is My code . But I couldn't Update the Records ...:
-----
try
{
if (txtFname.Text == FnameDataGrid && txtLname.Text == LnameDataGrid
&& txtRegNo.Text == RegNoDataGrid && txtYearReg.Text == YearRegDataGrid)
{
OleDbConnection ocn_Edited = new OleDbConnection(ConnectionStringEdited);
OleDbCommand ocmd_Edited = new OleDbCommand();
ocmd_Edited.CommandText = @"UPDATE RegTable SET FNAME=@p1,LNAME=@p2,
YearReg=@p3,RegNo=@p4,
WHERE YearReg=@g1
AND RegNo=@g2";
ocmd_Edited.Parameters.Clear();
ocmd_Edited.Parameters.AddWithValue("@p1", txtFname.Text);
ocmd_Edited.Parameters.AddWithValue("@p2", txtLname.Text);
ocmd_Edited.Parameters.AddWithValue("@p3", txtYearReg.Text);
ocmd_Edited.Parameters.AddWithValue("@p4", txtRegNo.Text);
ocmd_Edited.Parameters.AddWithValue("@g1", YearRegDataGrid);
ocmd_Edited.Parameters.AddWithValue("@g2", RegNoDataGrid);
ocmd_Edited.Connection = null;
ocmd_Edited.Connection = ocn_Edited;
ocn_Edited.Open();
ocmd_Edited.ExecuteNonQuery();
ocn_Edited.Close();
ocmd_Edited.Dispose();
ocn_Edited.Dispose();
MessageBox.Show(" ... This Table Updated ...");
frmShowGrd frmGrd = (frmShowGrd)Application.OpenForms["frmShowGrd"];
frmGrd.boolEdit = true;
frmGrd.FnameDataGrid_1 = txtFname.Text;
frmGrd.LnameDataGrid_1 = txtLname.Text;
frmGrd.YearRegDataGrid_1 = txtYearReg.Text;
frmGrd.RegNoDataGrid_1 = txtRegNo.Text;
this.Close();
}
else
{
OleDbConnection ocn = new OleDbConnection(ConnectionStringEdited);
strSql =@"SELECT RegNo WHERE RegNo=@s1 AND YearReg=@s2";
OleDbDataAdapter oda_Edited = new OleDbDataAdapter(strSql, ocn);
oda_Edited.SelectCommand.Parameters.Clear();
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s1", txtRegNo.Text);
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s2", txtYearReg.Text);
DataTable dt_Edited = new DataTable();
dt_Edited.Clear();
oda_Edited.Fill(dt_Edited);
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
else
{
OleDbCommand ocmd_Edited02 = new OleDbCommand();
ocmd_Edited02.CommandText = @"UPDATE RegTable SET FNAME=@t1,LNAME=@t2,
YearReg=@t3,RegNo=@t4,
WHERE YearReg=@e1
AND RegNo=@e2";
ocmd_Edited02.Parameters.Clear();
ocmd_Edited.Parameters.AddWithValue("@t1", txtFname.Text);
-----
I don't don't where's my Mistake .
Plz Help Me .
Thanks
modified 3-Sep-13 8:16am.
|
|
|
|
|
smh1392 wrote: But I couldn't Update the Records
What does that mean? Do you get an error message? If so, tell us the message. Does the table contain values different from those you expected? Does "first form" still show old values instead of the updated values? Anything else different from what you expected?
|
|
|
|
|
according to the code that I wrote above , I want to check the Value of "RegNo" (preventing duplicate the value of "RegNo" Field ), before Updating , but Always Execute this :
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
So my database never Update ...
....
Thanks
|
|
|
|
|
Is there is way to invoke solid edge using c#
Thanks
|
|
|
|
|
|
Thanks For reply
But not get proper answer
|
|
|
|
|
If you give a proper question, you'll get a proper answer. As I asked, what is Solid Edge? I could have assumed it was the CAD package, but that would have been an assumption which could have ended up wasting your time by supplying details of something that was completely inappropriate.
|
|
|
|
|
I Want to create Solid Edge drawing using C# application
Thanks
|
|
|
|
|
Again, WHAT IS SOLID EDGE??
When speaking with humans, the quality of the answer you get is directly dictated by the quality of the question you ask!
|
|
|
|
|
Thanks..
Solid edge is a software for making mechanical 3D drawings...I is just Like Autocad Software used for mechanical engineers drawings..
Thanks
|
|
|
|
|
The best place to ask your question would be the makers of SolidEdge, not a bunch of people who have never heard of it.
|
|
|
|
|
Not sure - but this set[^] of samples on Codeplex might help you.
|
|
|
|
|
|
My SQL command returns 3 rows which is verified in a SQL GUI. I run the same code and SqlDataReader returns only 2 of them. The same sql command returns 3 rows with SqlDataAdapter. Here is my code.
ds has 3 rows.
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["VPO"].ConnectionString))
{
string sql="SELECT DISTINCT A.account_id, A.fname, A.lname,
FROM T_Test1 A WITH (NOLOCK) JOIN T_Test2 AF WITH (NOLOCK) ON A.Account_id=AF.Account_id
WHERE account_status = 'A' AND A.card IS NOT NULL
AND A.dateFrom >= '09-02-2013 00:00:00' AND A.dateFrom <= '09-30-2013 00:00:00' AND AF.code = 'INE'";
SqlCommand command = new SqlCommand(sql.ToString(), connection);
command.CommandTimeout = 3600;
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
}
|
|
|
|
|