Click here to Skip to main content
15,895,462 members
Home / Discussions / C#
   

C#

 
QuestionCross threading issue [modified] Pin
JacquesDP16-Jan-07 20:08
JacquesDP16-Jan-07 20:08 
AnswerRe: Cross threading issue Pin
Christian Graus16-Jan-07 20:53
protectorChristian Graus16-Jan-07 20:53 
GeneralRe: Cross threading issue Pin
S. Senthil Kumar16-Jan-07 21:39
S. Senthil Kumar16-Jan-07 21:39 
GeneralRe: Cross threading issue Pin
JacquesDP16-Jan-07 23:34
JacquesDP16-Jan-07 23:34 
GeneralRe: Cross threading issue Pin
S. Senthil Kumar17-Jan-07 0:28
S. Senthil Kumar17-Jan-07 0:28 
GeneralRe: Cross threading issue Pin
JacquesDP17-Jan-07 0:51
JacquesDP17-Jan-07 0:51 
QuestionHow to read flat file into Dataset Pin
NK716-Jan-07 19:58
NK716-Jan-07 19:58 
AnswerRe: How to read flat file into Dataset Pin
Abisodun17-Jan-07 3:35
Abisodun17-Jan-07 3:35 
The following works for an Excel worksheet:

this.dataSet = GetDataset(worksheet, "BookName");

private DataSet GetDataset(Excel.Worksheet worksheet, string startElement)
{

StringBuilder stringBuilder = new StringBuilder();
XmlTextWriter xmlTextWriter = new XmlTextWriter(new StringWriter(stringBuilder));
xmlTextWriter.WriteStartDocument();
xmlTextWriter.Formatting = Formatting.Indented;
xmlTextWriter.Indentation = 3;

int row = 2;
Array rowValues = (Array)worksheet.get_Range("A" + row.ToString(), "C" + row.ToString()).Cells.Value2;
string Col1 = GetString(rowValues.GetValue(1, 1));
string Col2 = GetString(rowValues.GetValue(1, 2));
string Col3 = GetString(rowValues.GetValue(1, 3));
DataSet ds = new DataSet("table");

xmlTextWriter.WriteStartElement(startElement);

if (Col2 == string.Empty)
{
DataTable dataTable = new DataTable("row");
dataTable.Columns.Add("Col1");
dataTable.Columns.Add("Col2");
dataTable.Columns.Add("Col3");
dataTable.Rows.Add(new object[] { null, null, null });
ds.Tables.Add(dataTable);

return ds;
}



while (Col2 != string.Empty)
{
xmlTextWriter.WriteStartElement("row");
xmlTextWriter.WriteElementString("Col1", Col1);
xmlTextWriter.WriteElementString("Col2", Col2);
xmlTextWriter.WriteElementString("Col3", Col3);
xmlTextWriter.WriteEndElement();
row++;
rowValues = (Array)worksheet.get_Range("A" + row.ToString(), "C" + row.ToString()).Cells.Value2;
Col1 = GetString(rowValues.GetValue(1, 1));
Col2 = GetString(rowValues.GetValue(1, 2));
Col3 = GetString(rowValues.GetValue(1, 3));
}

xmlTextWriter.WriteEndElement();

xmlTextWriter.Flush();
xmlTextWriter.Close();


XmlTextReader xmlReader = new XmlTextReader(stringBuilder.ToString(), XmlNodeType.Element, null);
ds.ReadXml(xmlReader);

return ds;
}


For a flat file get rowValues array as follows:

StreamReader inStream = new StreamReader(filePath);

line = inStream.ReadLine();
while(inStream.Peek() >= 0)
{
line = inStream.ReadLine();
string[] rowValues = line.Split(new Char [] {','});//assumes flat file is comma delimited

}
inStream.Close();

Col1 = rowValues[1];
Col2 = rowValues[2];
Col3 = rowValues[3];
QuestionConnect SQL Server from client machine in C# [modified] Pin
phantanagu16-Jan-07 19:48
phantanagu16-Jan-07 19:48 
AnswerRe: Connect SQL Server from client machine in C# Pin
Elephant12316-Jan-07 20:56
Elephant12316-Jan-07 20:56 
Questionurgent How do we execute block of code only onces when we execute a program first time in C#.net Pin
Vinay Dornala16-Jan-07 19:46
Vinay Dornala16-Jan-07 19:46 
AnswerRe: urgent How do we execute block of code only onces when we execute a program first time in C#.net Pin
NK716-Jan-07 20:03
NK716-Jan-07 20:03 
AnswerRe: urgent How do we execute block of code only onces when we execute a program first time in C#.net Pin
JacquesDP16-Jan-07 20:14
JacquesDP16-Jan-07 20:14 
GeneralRe: urgent How do we execute block of code only onces when we execute a program first time in C#.net Pin
Vinay Dornala16-Jan-07 20:23
Vinay Dornala16-Jan-07 20:23 
GeneralRe: urgent How do we execute block of code only onces when we execute a program first time in C#.net Pin
JacquesDP16-Jan-07 20:30
JacquesDP16-Jan-07 20:30 
AnswerRe: urgent How do we execute block of code only onces when we execute a program first time in C#.net Pin
J4amieC16-Jan-07 22:43
J4amieC16-Jan-07 22:43 
Questionweb application Pin
raju_net181816-Jan-07 19:30
raju_net181816-Jan-07 19:30 
AnswerRe: web application Pin
jdkulkarni16-Jan-07 22:44
jdkulkarni16-Jan-07 22:44 
QuestionFile Attributes questions Pin
Planker16-Jan-07 19:10
Planker16-Jan-07 19:10 
Questionvisual studio can not start debugging Pin
chintan1816-Jan-07 18:53
chintan1816-Jan-07 18:53 
AnswerRe: visual studio can not start debugging Pin
Christian Graus16-Jan-07 19:26
protectorChristian Graus16-Jan-07 19:26 
AnswerRe: visual studio can not start debugging Pin
Seishin#16-Jan-07 22:56
Seishin#16-Jan-07 22:56 
QuestionWCF Service and JAVA client Pin
jdkulkarni16-Jan-07 18:34
jdkulkarni16-Jan-07 18:34 
AnswerRe: WCF Service and JAVA client Pin
KevinMac16-Jan-07 18:45
KevinMac16-Jan-07 18:45 
GeneralRe: WCF Service and JAVA client Pin
jdkulkarni16-Jan-07 18:52
jdkulkarni16-Jan-07 18: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.