Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
lookup using column headers and row headers | Excel Discussion (Misc queries) | |||
when are [ ] brackets used | Excel Worksheet Functions | |||
Hide Column Headers but not row (Headers) | Excel Programming | |||
help with brackets | Excel Discussion (Misc queries) | |||
=D6-E6 there are brackets? | Charts and Charting in Excel |