An invalid character in Select statement

General discussion forum about all things Team Developer 7.x
aspurga
Lithuania
Posts: 8
Joined: 06 Mar 2017, 08:54
Location: Lithuania

An invalid character in Select statement

Post by aspurga » 21 Aug 2017, 12:12

Hello,

Want just read an Excel file using OLEDB

Set sSql = "Select * from [Sheet1$]"
Set sOLEDBString = 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\\file.xls;Extended Properties="Excel 12.0;HDR=YES";'
Set SqlUser = ''
Set SqlDatabase = ''
Set SqlPassword = ''
Call SqlCreateSession( hSession, sOLEDBSessionProp )
Call SqlCreateStatement( hSession, hSql )
Call SqlConnect( hSql )
Call SalTblPopulate( grid1,hSql, sSql,TBL_FillAll)

TD reports an error "Invalid character" in Select statement. Without brackets [ and ] reports that table Sheet1$ has not been created.

What should be the correct Select statement?

Thanks

Arunas

aspurga
Lithuania
Posts: 8
Joined: 06 Mar 2017, 08:54
Location: Lithuania

Re: An invalid character in Select statement

Post by aspurga » 23 Aug 2017, 10:07

Hi,

The correct snippet below. It allows to read data from an Excel file.

Set sSql = "Select * from [Sheet1$]"
Set sOLEDBString = 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\\Excel file.xlsx;Extended Properties="Excel 12.0;HDR=YES;IMEX=1";'
Set SqlUser = ''
Set SqlDatabase = ''
Set SqlPassword = ''
If SqlCreateSession( hSession, sOLEDBString )
If SqlCreateStatement( hSession, hSql )
Call SalTblPopulate( tbl1, hSql, sSql, TBL_FillAll )
Call SqlDisconnect( hSql )

Return to “General Discussion”

Who is online

Users browsing this forum: Ccbot [Crawler] and 1 guest