Click here to Skip to main content
15,500,714 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
A Wong16-Jul-08 5:38
MemberA Wong16-Jul-08 5:38 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
A Wong16-Jul-08 5:50
MemberA Wong16-Jul-08 5:50 
AnswerRe: How to get the first rows of a relational table (depending of the last date of change) Pin
leoinfo16-Jul-08 5:29
Memberleoinfo16-Jul-08 5:29 
AnswerRe: How to get the first rows of a relational table (depending of the last date of change) Pin
leoinfo16-Jul-08 5:39
Memberleoinfo16-Jul-08 5:39 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
fracalifa16-Jul-08 5:56
Memberfracalifa16-Jul-08 5:56 
QuestionHow to Make Application to Sync on Remote Site Pin
Nassoro Ally16-Jul-08 1:39
MemberNassoro Ally16-Jul-08 1:39 
QuestionReports are not visible on client machine Pin
meetaqadir15-Jul-08 21:54
Membermeetaqadir15-Jul-08 21:54 
QuestionOLEDB with Excel problem Pin
acroitoriu15-Jul-08 21:52
Memberacroitoriu15-Jul-08 21:52 
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 any 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 spaces in the sheet name?

Thank you!

Andrei

------------
Croitoriu Andrei
andrei.croitoriu@gmail.com
http://www.stud.usv.ro/~acroitoriu
http://spaces.msn.com/acroitoriu/
"No complexity beyond what is necessary"

AnswerRe: OLEDB with Excel problem Pin
acroitoriu15-Jul-08 22:23
Memberacroitoriu15-Jul-08 22:23 
Questionfacing probs in nested cursor Pin
Member 387988115-Jul-08 20:56
MemberMember 387988115-Jul-08 20:56 
AnswerRe: facing probs in nested cursor Pin
Alsvha16-Jul-08 0:28
MemberAlsvha16-Jul-08 0:28 
Questionbytes retrieval Pin
vicki52815-Jul-08 19:19
Membervicki52815-Jul-08 19:19 
AnswerRe: bytes retrieval Pin
Alsvha16-Jul-08 0:28
MemberAlsvha16-Jul-08 0:28 
QuestionHow do i convert a varchar field into the datetime data type Pin
Rameez Raja15-Jul-08 19:12
MemberRameez Raja15-Jul-08 19:12 
AnswerRe: How do i convert a varchar field into the datetime data type Pin
Alsvha16-Jul-08 0:31
MemberAlsvha16-Jul-08 0:31 
QuestionDATABASE CONNECTIVITY Pin
murphy7715-Jul-08 16:58
Membermurphy7715-Jul-08 16:58 
AnswerRe: DATABASE CONNECTIVITY Pin
Ashfield15-Jul-08 22:45
MemberAshfield15-Jul-08 22:45 
QuestionConnecting to an ODBC DataSource Pin
ffowler15-Jul-08 15:17
Memberffowler15-Jul-08 15:17 
QuestionDatabase Publishing Wizard alternatives Pin
Todd Smith15-Jul-08 10:15
MemberTodd Smith15-Jul-08 10:15 
AnswerRe: Database Publishing Wizard alternatives Pin
Alsvha16-Jul-08 0:34
MemberAlsvha16-Jul-08 0:34 
Questionautomatica fire event Pin
Member 387988115-Jul-08 5:12
MemberMember 387988115-Jul-08 5:12 
AnswerRe: automatica fire event Pin
Mark J. Miller15-Jul-08 8:07
MemberMark J. Miller15-Jul-08 8:07 
QuestionHow to make subreport display based on data Pin
imranafsari15-Jul-08 2:25
Memberimranafsari15-Jul-08 2:25 
AnswerRe: How to make subreport display based on data Pin
TheFM23415-Jul-08 6:33
MemberTheFM23415-Jul-08 6:33 
QuestionResetting Identity Column in oracle Pin
meeram39515-Jul-08 0:45
Membermeeram39515-Jul-08 0: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.