Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default headers contains brackets

Hi

How do I do a select from a excel sheet where the column header contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect, strConn);

Regards
Kim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default headers contains brackets

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in message
...
Hi

How do I do a select from a excel sheet where the column header contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect, strConn);

Regards
Kim


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default headers contains brackets

Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in message
...
Hi

How do I do a select from a excel sheet where the column header contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect, strConn);

Regards
Kim


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default headers contains brackets

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in message
...
Hi

How do I do a select from a excel sheet where the column header contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect, strConn);

Regards
Kim


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default headers contains brackets

Thanks. I know the alias method, but the problem is not add the data to the
datatable, but to select the row from the excel file, where the header
contain brackets.

Kim

"Patrick Molloy" wrote:

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in message
...
Hi

How do I do a select from a excel sheet where the column header contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect, strConn);

Regards
Kim



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default headers contains brackets

did you get anywhere with this?
I wasn't able to get past discovering that the field name went from [ID] to
(ID) in the recordset which didn't really help as i had to use SELECT * FROM
...
and wasn't able to use the field name itself

"Kim Carlsen" wrote in message
...
Thanks. I know the alias method, but the problem is not add the data to
the
datatable, but to select the row from the excel file, where the header
contain brackets.

Kim

"Patrick Molloy" wrote:

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in message
...
Hi

How do I do a select from a excel sheet where the column header
contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect,
strConn);

Regards
Kim

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default headers contains brackets


Hi

No I couldn't figure it out.

"Patrick Molloy" wrote:

did you get anywhere with this?
I wasn't able to get past discovering that the field name went from [ID] to
(ID) in the recordset which didn't really help as i had to use SELECT * FROM
..
and wasn't able to use the field name itself

"Kim Carlsen" wrote in message
...
Thanks. I know the alias method, but the problem is not add the data to
the
datatable, but to select the row from the excel file, where the header
contain brackets.

Kim

"Patrick Molloy" wrote:

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in message
...
Hi

How do I do a select from a excel sheet where the column header
contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect,
strConn);

Regards
Kim

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default headers contains brackets


I saved an excel workbook with [Instrument] as the column header, including
the square braces
I noiticed in SQL that Excel changed this to (Instrument) when I used SELECT
* FROM

so I tried this

SQL = "SELECT [(Instrument)] FROM [Instruments]"

and yes, it worked!




"Kim Carlsen" wrote in message
...
Hi

No I couldn't figure it out.

"Patrick Molloy" wrote:

did you get anywhere with this?
I wasn't able to get past discovering that the field name went from [ID]
to
(ID) in the recordset which didn't really help as i had to use SELECT *
FROM
..
and wasn't able to use the field name itself

"Kim Carlsen" wrote in message
...
Thanks. I know the alias method, but the problem is not add the data to
the
datatable, but to select the row from the excel file, where the header
contain brackets.

Kim

"Patrick Molloy" wrote:

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in
message
...
Hi

How do I do a select from a excel sheet where the column header
contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect,
strConn);

Regards
Kim

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default headers contains brackets


Thanks for helping this out.

that worked perfectly.

Kim

"Patrick Molloy" wrote:

I saved an excel workbook with [Instrument] as the column header, including
the square braces
I noiticed in SQL that Excel changed this to (Instrument) when I used SELECT
* FROM

so I tried this

SQL = "SELECT [(Instrument)] FROM [Instruments]"

and yes, it worked!




"Kim Carlsen" wrote in message
...
Hi

No I couldn't figure it out.

"Patrick Molloy" wrote:

did you get anywhere with this?
I wasn't able to get past discovering that the field name went from [ID]
to
(ID) in the recordset which didn't really help as i had to use SELECT *
FROM
..
and wasn't able to use the field name itself

"Kim Carlsen" wrote in message
...
Thanks. I know the alias method, but the problem is not add the data to
the
datatable, but to select the row from the excel file, where the header
contain brackets.

Kim

"Patrick Molloy" wrote:

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in
message
...
Hi

How do I do a select from a excel sheet where the column header
contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect,
strConn);

Regards
Kim

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default headers contains brackets


excellent

"Kim Carlsen" wrote in message
...
Thanks for helping this out.

that worked perfectly.

Kim

"Patrick Molloy" wrote:

I saved an excel workbook with [Instrument] as the column header,
including
the square braces
I noiticed in SQL that Excel changed this to (Instrument) when I used
SELECT
* FROM

so I tried this

SQL = "SELECT [(Instrument)] FROM [Instruments]"

and yes, it worked!




"Kim Carlsen" wrote in message
...
Hi

No I couldn't figure it out.

"Patrick Molloy" wrote:

did you get anywhere with this?
I wasn't able to get past discovering that the field name went from
[ID]
to
(ID) in the recordset which didn't really help as i had to use SELECT
*
FROM
..
and wasn't able to use the field name itself

"Kim Carlsen" wrote in message
...
Thanks. I know the alias method, but the problem is not add the data
to
the
datatable, but to select the row from the excel file, where the
header
contain brackets.

Kim

"Patrick Molloy" wrote:

do you have the SQL?

you can change the column name

eg: select tablex from dbtable
will return tablex as the header

while
select tablex as [X] from dbtable
will return X as the header.



"Kim Carlsen" wrote in
message
...
Hi

Yes it just gives me
"Syntax error in query expression '[[ID]]'."


regards
Kim
"Patrick Molloy" wrote:

have you tried
String strSelect = "SELECT [[ID]] FROM [sheetname$]"

"Kim Carlsen" wrote in
message
...
Hi

How do I do a select from a excel sheet where the column
header
contain
brackets? the actual name is [ID] ? I
i can't see how to escape correctly.
The code looks like:

String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=c:\test.xlsx;Extended Properties=Excel 12.0;";
String strSelect = "SELECT [ID] FROM [sheetname$]";
OleDbDataAdapter daMaster = new OleDbDataAdapter(strSelect,
strConn);

Regards
Kim

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
lookup using column headers and row headers Memphus01 Excel Discussion (Misc queries) 1 April 13th 09 04:57 PM
when are [ ] brackets used cmat Excel Worksheet Functions 2 October 21st 08 10:35 PM
Hide Column Headers but not row (Headers) Kevan Gradwell Excel Programming 1 March 16th 07 05:59 PM
help with brackets tombradshawuk Excel Discussion (Misc queries) 3 November 17th 06 10:19 PM
=D6-E6 there are brackets? JillM Charts and Charting in Excel 1 July 21st 06 08:03 PM


All times are GMT +1. The time now is 06:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"