Click here to Skip to main content
15,918,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: zipping Pin
S. Senthil Kumar8-Jul-05 1:54
S. Senthil Kumar8-Jul-05 1:54 
GeneralSystem.StackOverflowException Pin
fady_sayegh7-Jul-05 23:34
fady_sayegh7-Jul-05 23:34 
GeneralRe: System.StackOverflowException Pin
Guffa8-Jul-05 0:27
Guffa8-Jul-05 0:27 
GeneralMDI parent dynamic background Pin
_Kalix7-Jul-05 23:22
_Kalix7-Jul-05 23:22 
Questionhow to use namespace Nant.core Pin
dilsudharaka7-Jul-05 23:20
dilsudharaka7-Jul-05 23:20 
GeneralStreamReader.ReadLine() Problem Pin
byang7-Jul-05 22:23
byang7-Jul-05 22:23 
GeneralRe: StreamReader.ReadLine() Problem Pin
Steven Behnke9-Jul-05 19:26
Steven Behnke9-Jul-05 19:26 
GeneralMS Access to MS Excel with C# Pin
kbalias7-Jul-05 21:42
kbalias7-Jul-05 21:42 
Hi all

We need to do a small application that, amongst other things, need to extract some data from a MS Access database into a MS Excel worksheet. Connecting from my C# windows application I can connect to the MS Access database and extract the necessary data using the Jet driver (Microsoft.Jet.OLEDB). I am reading the data into a OleDbDataReader.

I am not sure how to do the MS Excel part. I would like to use the Jet driver (Microsoft.Jet.OLEDB). for this too, because then I do not have to reference the Microsoft Excel COM library in my project (as far as I know).

The following type of code works to open the connection to my Excel worksheet, but how would I add the records from my OleDbDataReader into the worksheet. Possible code probably needs to be where the ”XXXXXXXXXXXXXXXX” is in the code.

private void UpdateExcel()
{
OleDbConnection cnExcel = null;
try
{
Cursor.Current = Cursors.WaitCursor;
StringBuilder sbConn = new StringBuilder();
sbConn.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Stocks.XLS");
sbConn.Append(";Extended Properties=");
sbConn.Append(Convert.ToChar(34));
sbConn.Append("Excel 8.0;HDR=No;IMEX=2");
sbConn.Append(Convert.ToChar(34));
cnExcel = new OleDbConnection(sbConn.ToString());
cnExcel.Open();

OleDbCommand cmdExcel = new OleDbCommand("XXXXXXXXXXXXXXXX",cnExcel);
cmdExcel.ExecuteNonQuery();
cnExcel.Close();
Cursor.Current = Cursors.Arrow;
}
catch(Exception ex)
{
cnExcel.Close();
MessageBox.Show(ex.Message);
}
}


Alternatively is there a better, more streamlined way?? Perhaps something like the Data Transformation Services in SQL Server where I can export from Access into Excel? If there is, how could I do that from within C#?




GeneralRe: MS Access to MS Excel with C# Pin
Rob Graham8-Jul-05 8:21
Rob Graham8-Jul-05 8:21 
GeneralRE:SAVE BUTTON Pin
tatchung7-Jul-05 20:05
tatchung7-Jul-05 20:05 
GeneralQuestion regarding calling C++ DLL's from C# Pin
kroller7-Jul-05 19:03
kroller7-Jul-05 19:03 
GeneralRe: Question regarding calling C++ DLL's from C# Pin
Luis Alonso Ramos7-Jul-05 19:43
Luis Alonso Ramos7-Jul-05 19:43 
GeneralRe: Question regarding calling C++ DLL's from C# Pin
S. Senthil Kumar7-Jul-05 21:22
S. Senthil Kumar7-Jul-05 21:22 
GeneralDataset Pin
skrishnasarma7-Jul-05 18:08
skrishnasarma7-Jul-05 18:08 
GeneralRe: Dataset Pin
Christian Graus7-Jul-05 18:26
protectorChristian Graus7-Jul-05 18:26 
GeneralRe: Dataset Pin
skrishnasarma7-Jul-05 18:39
skrishnasarma7-Jul-05 18:39 
GeneralRe: Dataset Pin
Christian Graus7-Jul-05 18:46
protectorChristian Graus7-Jul-05 18:46 
GeneralRe: Dataset Pin
Luis Alonso Ramos7-Jul-05 19:46
Luis Alonso Ramos7-Jul-05 19:46 
QuestionCan any one help me? Pin
pubududilena7-Jul-05 18:02
pubududilena7-Jul-05 18:02 
AnswerRe: Can any one help me? Pin
Christian Graus7-Jul-05 18:29
protectorChristian Graus7-Jul-05 18:29 
QuestionHow to get client IP Pin
yunshan507-Jul-05 17:04
yunshan507-Jul-05 17:04 
AnswerRe: How to get client IP Pin
Luis Alonso Ramos7-Jul-05 19:50
Luis Alonso Ramos7-Jul-05 19:50 
GeneralRe: How to get client IP Pin
yunshan5010-Jul-05 23:19
yunshan5010-Jul-05 23:19 
GeneralRe: How to get client IP Pin
Luis Alonso Ramos11-Jul-05 5:16
Luis Alonso Ramos11-Jul-05 5:16 
Generalport Pin
amin saffari7-Jul-05 16:53
amin saffari7-Jul-05 16:53 

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.