Click here to Skip to main content
15,905,912 members
Home / Discussions / C#
   

C#

 
AnswerRe: c# Pin
J4amieC16-Jul-08 22:18
J4amieC16-Jul-08 22:18 
AnswerRe: c# Pin
Giorgi Dalakishvili16-Jul-08 22:25
mentorGiorgi Dalakishvili16-Jul-08 22:25 
AnswerRe: c# Pin
sumit703416-Jul-08 23:24
sumit703416-Jul-08 23:24 
AnswerRe: c# Pin
nelsonpaixao17-Jul-08 12:54
nelsonpaixao17-Jul-08 12:54 
QuestionDeploying app.config Pin
Christian Flutcher16-Jul-08 21:27
Christian Flutcher16-Jul-08 21:27 
AnswerRe: Deploying app.config Pin
Simon P Stevens17-Jul-08 0:19
Simon P Stevens17-Jul-08 0:19 
QuestionHow to share dlls in different applications ? Pin
jamesjk16-Jul-08 21:24
jamesjk16-Jul-08 21:24 
AnswerRe: How to share dlls in different applications ? Pin
Christian Flutcher16-Jul-08 21:29
Christian Flutcher16-Jul-08 21:29 
QuestionByte to Bits String Pin
half-life16-Jul-08 20:47
half-life16-Jul-08 20:47 
AnswerRe: Byte to Bits String Pin
Guffa16-Jul-08 20:56
Guffa16-Jul-08 20:56 
GeneralRe: Byte to Bits String Pin
half-life16-Jul-08 21:02
half-life16-Jul-08 21:02 
GeneralRe: Byte to Bits String Pin
leppie17-Jul-08 2:08
leppie17-Jul-08 2:08 
GeneralRe: Byte to Bits String Pin
PIEBALDconsult17-Jul-08 5:09
mvePIEBALDconsult17-Jul-08 5:09 
GeneralRe: Byte to Bits String Pin
Guffa17-Jul-08 7:19
Guffa17-Jul-08 7:19 
GeneralRe: Byte to Bits String Pin
PIEBALDconsult17-Jul-08 14:58
mvePIEBALDconsult17-Jul-08 14:58 
AnswerRe: Byte to Bits String Pin
PIEBALDconsult17-Jul-08 5:19
mvePIEBALDconsult17-Jul-08 5:19 
QuestionOLEDB with Excel problem Pin
acroitoriu16-Jul-08 20:18
acroitoriu16-Jul-08 20:18 
Hi,

I have a simple method that checks if a sheet name is present in the excel file or not. The code is simple and works fine when the sheet name doesn't contain any spaces:

private bool validateExcelSheetByName(string name, OleDbConnection connection) {
bool result = true;
try {
if (connection.State == ConnectionState.Closed)
connection.Open();
var command = new OleDbCommand(string.Format("select * from [{0}]", name), connection);
command.ExecuteNonQuery();
}
catch {
result = false;
if (connection.State == ConnectionState.Open)
connection.Close();
}
return result;
}

In case I have a dot and a space in the sheet name (for example 'My. Sheet'), I get an exception saying:
Invalid bracketing of name 'My. Sheet$'.

I store the sheet name in a variable:
private const string sheetName = "My. Sheet$";

How can I fix this code so it will work when I have dots and spaces in the sheet name?

Thank you!

Andrei
AnswerRe: OLEDB with Excel problem Pin
dan!sh 16-Jul-08 20:44
professional dan!sh 16-Jul-08 20:44 
GeneralRe: OLEDB with Excel problem Pin
acroitoriu17-Jul-08 21:41
acroitoriu17-Jul-08 21:41 
Questionusing a variable on two different forms Pin
programming.student16-Jul-08 19:04
programming.student16-Jul-08 19:04 
AnswerRe: using a variable on two different forms Pin
N a v a n e e t h16-Jul-08 19:52
N a v a n e e t h16-Jul-08 19:52 
GeneralRe: using a variable on two different forms Pin
programming.student16-Jul-08 20:15
programming.student16-Jul-08 20:15 
GeneralRe: using a variable on two different forms Pin
Alex@UEA16-Jul-08 23:45
Alex@UEA16-Jul-08 23:45 
AnswerRe: using a variable on two different forms Pin
Ajay.k_Singh16-Jul-08 20:22
Ajay.k_Singh16-Jul-08 20:22 
GeneralRe: using a variable on two different forms Pin
V.16-Jul-08 21:48
professionalV.16-Jul-08 21:48 

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.