Click here to Skip to main content
15,886,724 members
Home / Discussions / C#
   

C#

 
GeneralFind & Copy part of string Pin
Steve McLenithan10-Jan-03 6:52
Steve McLenithan10-Jan-03 6:52 
GeneralRe: Find & Copy part of string Pin
leppie10-Jan-03 6:59
leppie10-Jan-03 6:59 
GeneralRe: Find & Copy part of string Pin
Steve McLenithan10-Jan-03 7:02
Steve McLenithan10-Jan-03 7:02 
Generaldelegate ordering Pin
Shaun Wilde10-Jan-03 5:15
Shaun Wilde10-Jan-03 5:15 
GeneralRe: delegate ordering Pin
Nick Parker10-Jan-03 5:58
protectorNick Parker10-Jan-03 5:58 
GeneralRe: delegate ordering Pin
Shaun Wilde10-Jan-03 6:06
Shaun Wilde10-Jan-03 6:06 
GeneralRe: delegate ordering Pin
leppie10-Jan-03 6:07
leppie10-Jan-03 6:07 
GeneralExport to Excel Problem Pin
Jassim Rahma10-Jan-03 0:10
Jassim Rahma10-Jan-03 0:10 
I'm using the following code to export from a database to Microsoft Excel but I have one problem: The first record in the database is not getting exported correctly, any one can tell me why?

Many Thanks,
Jassim Rahma


string myConnString = ConnectionString;

OdbcConnection cn = new OdbcConnection(myConnString);
cn.Open();
cn.ChangeDatabase(TableName);

DataSet ds = new DataSet();
OdbcDataAdapter da = new OdbcDataAdapter(SQLstatement, cn);

da.Fill(ds, TableName);

if (MessageBox.Show("Do you want to Export the data?", "Export", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{

string MyString;

StreamWriter myTextStream = new StreamWriter(txtOutput.Text);

for (int i= 0; i < ds.Tables[0].Columns.Count-2; i++)
{
MyString = ds.Tables[0].Columns[i].ToString() + ", ";
}

MyString = ds.Tables[0].Columns[ds.Tables[0].Columns.Count-1].ToString();

myTextStream.WriteLine(MyString);
MyString = "";

System.Data.DataTable tb = ds.Tables[0];

for (int i = 0; i < tb.Rows.Count-1; i++)
{
System.Data.DataRow dr = tb.Rows[i];
for (int j = 0; j < dr.Table.Columns.Count-2; j++)
{
MyString = MyString + dr[j].ToString() + ", ";
}
MyString = MyString + dr[dr.Table.Columns.Count-1].ToString();
myTextStream.WriteLine(MyString);
MyString = "";
}

myTextStream.Close();
myTextStream = null;

Process p = new Process();
System.Diagnostics.ProcessStartInfo pi = new ProcessStartInfo();
pi.UseShellExecute = true;
pi.WindowStyle = ProcessWindowStyle.Hidden;
pi.FileName= txtOutput.Text;
p.StartInfo = pi;
p.Start();
}

cn.Close();
cn.Close();
}

Jassim Rahma
GeneralCommandbars Pin
suresh_sathya9-Jan-03 20:18
suresh_sathya9-Jan-03 20:18 
QuestionInclude Dll's in Build? Pin
granthnk9-Jan-03 16:54
granthnk9-Jan-03 16:54 
AnswerRe: Include Dll's in Build? Pin
Stephane Rodriguez.9-Jan-03 21:09
Stephane Rodriguez.9-Jan-03 21:09 
QuestionHow to get control reference from handle? Pin
FruitBatInShades9-Jan-03 14:01
FruitBatInShades9-Jan-03 14:01 
AnswerRe: How to get control reference from handle? Pin
leppie9-Jan-03 20:51
leppie9-Jan-03 20:51 
GeneralStatic TextBoxt that keeps disappearing Pin
laphijia9-Jan-03 13:43
laphijia9-Jan-03 13:43 
GeneralRe: Static TextBoxt that keeps disappearing Pin
FruitBatInShades9-Jan-03 14:07
FruitBatInShades9-Jan-03 14:07 
GeneralRe: Static TextBoxt that keeps disappearing Pin
laphijia9-Jan-03 21:33
laphijia9-Jan-03 21:33 
Generalweird MSCORLIB Exception Pin
matthias s.9-Jan-03 11:36
matthias s.9-Jan-03 11:36 
GeneralRe: weird MSCORLIB Exception Pin
leppie9-Jan-03 12:13
leppie9-Jan-03 12:13 
GeneralRe: weird MSCORLIB Exception Pin
matthias s.10-Jan-03 6:33
matthias s.10-Jan-03 6:33 
GeneralRe: weird MSCORLIB Exception Pin
leppie10-Jan-03 6:55
leppie10-Jan-03 6:55 
GeneralRe: weird MSCORLIB Exception Pin
matthias s.10-Jan-03 7:32
matthias s.10-Jan-03 7:32 
GeneralRe: weird MSCORLIB Exception - Solution Pin
matthias s.10-Jan-03 7:47
matthias s.10-Jan-03 7:47 
GeneralRe: weird MSCORLIB Exception Pin
James T. Johnson10-Jan-03 18:31
James T. Johnson10-Jan-03 18:31 
GeneralRe: weird MSCORLIB Exception Pin
leppie11-Jan-03 0:23
leppie11-Jan-03 0:23 
Question'Subclassing' child controls. Is it possible? Pin
FruitBatInShades9-Jan-03 10:45
FruitBatInShades9-Jan-03 10:45 

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.