Click here to Skip to main content
16,020,669 members
Home / Discussions / C#
   

C#

 
AnswerRe: Looping through XMLNodeList problem Pin
#realJSOP11-Jan-10 3:31
professional#realJSOP11-Jan-10 3:31 
QuestionHow do I get the location and size of the upper leftmost cell in a DataGridView? Pin
arnold_w10-Jan-10 22:25
arnold_w10-Jan-10 22:25 
AnswerRe: How do I get the location and size of the upper leftmost cell in a DataGridView? Pin
sanforjackass10-Jan-10 23:55
sanforjackass10-Jan-10 23:55 
GeneralRe: How do I get the location and size of the upper leftmost cell in a DataGridView? Pin
arnold_w11-Jan-10 0:02
arnold_w11-Jan-10 0:02 
Questionappending text Pin
Member 59031010-Jan-10 22:23
Member 59031010-Jan-10 22:23 
AnswerRe: appending text Pin
Nicholas Butler10-Jan-10 22:27
sitebuilderNicholas Butler10-Jan-10 22:27 
AnswerRe: appending text Pin
Abhinav S10-Jan-10 22:59
Abhinav S10-Jan-10 22:59 
QuestionCant Write Large Text File Pin
salamonty8610-Jan-10 21:49
salamonty8610-Jan-10 21:49 
Dear all,

I want to create a large .txt file but when i run my code i got a strange thing,
A messagebox say's: "No Symbols are loaded for any call stack frame. The source code cannot be displayed."

and a warning say's "The CLR has been unable to transition from COM context 0x1c2000 to COM context 0x1c2170 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."


My code is:
string prev="";<br />
<br />
            string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;data source=E:\\ICA_Newspapers.mdb";<br />
<br />
            OleDbConnection conn = new OleDbConnection(connectionString);<br />
<br />
            string sql = "SELECT * FROM All_Analyzed_Corpus";<br />
<br />
            OleDbCommand cmd = new OleDbCommand(sql, conn);<br />
<br />
            conn.Open();<br />
<br />
            OleDbDataReader reader;<br />
            reader = cmd.ExecuteReader();<br />
<br />
            StreamWriter tw = new StreamWriter(Application.StartupPath + "\\TaggedCorpus.txt");<br />
<br />
            StringBuilder text = new StringBuilder();<br />
            <br />
            <br />
            while (reader.Read())<br />
            {<br />
                //if new line<br />
                if (reader.GetValue(1).ToString() == "/D")<br />
                {<br />
                    //if end of line<br />
                    text.Append("</s>");<br />
                    //text.Capacity = text.Length;<br />
                    // write a line of text to the file<br />
                    <br />
                    tw.WriteLine(text);<br />
                    tw.Flush();<br />
                    text = text.Remove(0, text.Length);<br />
<br />
                    text.Append("<s> ");<br />
                    prev = "/D";<br />
                }<br />
                else if (reader.GetValue(1).ToString() == "/T" && prev != "/D")<br />
                {<br />
                    //if end of line<br />
                    text.Append("</s>");<br />
                    //text.Capacity = text.Length;<br />
                    // write a line of text to the file<br />
                    tw.WriteLine(text);<br />
                    tw.Flush();<br />
                    <br />
                    text = text.Remove(0, text.Length);<br />
<br />
                    text.Append("<s> ");<br />
                    prev = "/T";<br />
                }<br />
                else if (reader.GetValue(1).ToString() == "/P" && prev != "/T")<br />
                {<br />
                    //if end of line<br />
                    text.Append("</s>");<br />
                    //text.Capacity = text.Length;<br />
                    // write a line of text to the file<br />
                    tw.WriteLine(text);<br />
                    tw.Flush();<br />
<br />
                    text = text.Remove(0, text.Length);<br />
<br />
                    text.Append("<s> ");<br />
                    prev = "/P";<br />
                }<br />
<br />
                <br />
<br />
                if(reader.GetValue(5).ToString().Contains("/"))<br />
                {<br />
                    pr1 = reader.GetValue(5).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    pr1 = reader.GetValue(5).ToString();<br />
                }<br />
<br />
                if (reader.GetValue(6).ToString().Contains("/"))<br />
                {<br />
                    pr2 = reader.GetValue(6).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    pr2 = reader.GetValue(6).ToString();<br />
                }<br />
<br />
                if (reader.GetValue(7).ToString().Contains("/"))<br />
                {<br />
                    pr3 = reader.GetValue(7).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    pr3 = reader.GetValue(7).ToString();<br />
                }<br />
                if (reader.GetValue(8).ToString().Contains("/"))<br />
                {<br />
                    stm = reader.GetValue(8).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    stm = reader.GetValue(8).ToString();<br />
                }<br />
<br />
                if (reader.GetValue(9).ToString().Contains("/"))<br />
                {<br />
                    suf1 = reader.GetValue(9).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    suf1 = reader.GetValue(9).ToString();<br />
                }<br />
<br />
                if (reader.GetValue(10).ToString().Contains("/"))<br />
                {<br />
                    suf2 = reader.GetValue(10).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    suf2 = reader.GetValue(10).ToString();<br />
                }<br />
<br />
                if (reader.GetValue(14).ToString().Contains("/"))<br />
                {<br />
                    cas = reader.GetValue(14).ToString().Split(char.Parse("/"))[1];<br />
                }<br />
                else<br />
                {<br />
                    cas = reader.GetValue(14).ToString();<br />
                }<br />
<br />
<br />
                text.Append(pr1 + "+" + pr2 + "+"<br />
                    + pr3 + "+" + stm + "+" + suf1<br />
                    + "+" + suf2 + "+" + cas + " ");<br />
<br />
<br />
                text = text.Replace(" +", " #+");<br />
                text = text.Replace("+++", "+#+#+");<br />
                text = text.Replace("++", "+#+");<br />
                text = text.Replace("+ ", "+# ");<br />
<br />
                //Thread.Sleep(2000);<br />
                //tw.Close();<br />
                <br />
            }<br />
<br />
            // close the stream<br />
            tw.Close();<br />
            <br />
            reader.Close();<br />
            conn.Close();<br />
<br />


Thanks in advance...
AnswerRe: Cant Write Large Text File Pin
Covean10-Jan-10 22:13
Covean10-Jan-10 22:13 
GeneralRe: Cant Write Large Text File Pin
salamonty8611-Jan-10 0:27
salamonty8611-Jan-10 0:27 
GeneralRe: Cant Write Large Text File Pin
Covean11-Jan-10 1:19
Covean11-Jan-10 1:19 
QuestionMaking a maths solver Pin
Matt Cavanagh10-Jan-10 21:37
Matt Cavanagh10-Jan-10 21:37 
AnswerRe: Making a maths solver Pin
Rob Philpott10-Jan-10 22:13
Rob Philpott10-Jan-10 22:13 
GeneralRe: Making a maths solver Pin
Matt Cavanagh10-Jan-10 22:31
Matt Cavanagh10-Jan-10 22:31 
AnswerRe: Making a maths solver Pin
PIEBALDconsult11-Jan-10 3:53
mvePIEBALDconsult11-Jan-10 3:53 
QuestionHow to convert text file pdf? Pin
Sunil G10-Jan-10 21:37
Sunil G10-Jan-10 21:37 
AnswerMessage Closed Pin
10-Jan-10 22:13
stancrm10-Jan-10 22:13 
GeneralRe: How to export data into excel or pdf? Pin
Sunil G10-Jan-10 23:06
Sunil G10-Jan-10 23:06 
GeneralRe: How to export data into excel or pdf? Pin
Dave Kreskowiak11-Jan-10 1:13
mveDave Kreskowiak11-Jan-10 1:13 
GeneralRe: How to export data into excel or pdf? Pin
Sunil G11-Jan-10 21:44
Sunil G11-Jan-10 21:44 
GeneralRe: How to export data into excel or pdf? Pin
Dave Kreskowiak12-Jan-10 1:10
mveDave Kreskowiak12-Jan-10 1:10 
Questionbuffer size in c# Pin
anishkannan10-Jan-10 21:34
anishkannan10-Jan-10 21:34 
AnswerRe: buffer size in c# Pin
Nicholas Butler10-Jan-10 21:42
sitebuilderNicholas Butler10-Jan-10 21:42 
GeneralRe: buffer size in c# Pin
anishkannan10-Jan-10 23:28
anishkannan10-Jan-10 23:28 
QuestionRefresh form1 from form2 Pin
misCafe10-Jan-10 20:52
misCafe10-Jan-10 20:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.