Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hello!

Does the ADO driver support prepared statements at all, or am I doing
something wrong? I'm experimenting with LibreOffice Basic and MS SQL Server
2008 R2, trying to read rows from a database with the ADO driver and a
prepared statement. I have old ODBC code that works against MSSQL, but for
some reason I can't get the ADO version to work.

 I have set up a simple test table (tbl1) like this:
col1 (integer); col2 (varchar(12))
1; aaaa
2; bbbb
3; cccc

I'm trying to get a row from the table with a prepared statement like this:
Sub test
Dim DatabaseContext As Object
Dim flatProp(0) As New com.sun.star.beans.PropertyValue
Dim Connection As Object
Dim Statement As Object
Dim ResultSet As Object

DatabaseContext = createUnoService("com.sun.star.comp.sdbc.ado.ODriver")
Connection = DatabaseContext.connect("sdbc:ado:PROVIDER=sqloledb;DATA
SOURCE=myserver;INITIAL CATALOG=mydb;USER ID=user;PASSWORD=pwd", flatProp())
Statement = Connection.prepareStatement("SELECT col1 FROM tbl1 WHERE col2 =
?")
Statement.setString(1, "bbbb")
ResultSet = Statement.executeQuery()
MsgBox ResultSet.getString(1)
End Sub

When I run the script, I get a com.sun.star.sdbc.SQLException (Incorrect
syntax near ':'..) at the executeQuery() line.

If I replace the question mark in the query with 'bbbb' the code works fine.



--
View this message in context: 
http://nabble.documentfoundation.org/SQLException-when-using-ADO-driver-and-prepared-statements-tp4070605.html
Sent from the Users mailing list archive at Nabble.com.

-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.