Manolis Christodoulou wrote:
I have a Base (HSQLDB) file with table MyTable(MyField1, MyField2).
I have a form in that ODB file to display MyTable.
The following code in the form will not work:

Dim conn as Variant
Dim stat as Variant
Dim rs as Variant
conn=ThisComponent.Parent.DataSource.GetConnenction("","")
stat=conn.createStatement()
rs=stat.executeQuery("SELECT MyField1 FROM MyTable"

It gives a runtime error on the last line telling me eather that the Field or the Table does not exist unless I had created the table and all the fields inside using capital letters, like MYTABLE, MYFIELD1, MYFIELD2, and of course if I also had capitalised the names in the executeQuery call.

Can anyone reproduce this?


I think that in AndrewBase.odt, I discuss this problem and the fact that you should quote table names and column names using the quote character returned from meta-data available from the connection. For example:


If a field name contains a space or lower case letters, then the field name must be quoted. The character used for quoting changes depending on the database in question. Common quote characters include a back-tic (`), single quote ('), or double quote ("). The precise character to use is obtainable from the connection meta-data.

/Listing 74: Quote a table or field name in a SQL statement./

REM The quote charcter changes based on the database that is accessed.

Function DBQuoteName(sName As String, oCon) As String

Dim sQuote As String

sQuote = oCon.getMetaData().getIdentifierQuoteString()

DBQuoteName = sQuote & sName & sQuote

End Function


and also on page of the document.....





--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to