<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fdata_sources</id>
	<title>EN/documentation/basic guide/data sources - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fdata_sources"/>
	<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/data_sources&amp;action=history"/>
	<updated>2026-11-11T13:55:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/data_sources&amp;diff=16631&amp;oldid=prev</id>
		<title>Sancho: Created page with &quot;&lt;section begin=title /&gt;&lt;noinclude&gt;{{DISPLAYTITLE:&lt;/noinclude&gt;Data Sources&lt;noinclude&gt;}}&lt;/noinclude&gt;&lt;section end=title /&gt;{{BreadCrumbL10n}}  {{Documentation/BASICGuideTOC |ShowPrev...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/data_sources&amp;diff=16631&amp;oldid=prev"/>
		<updated>2011-09-05T17:23:29Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;Data Sources&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}  {{Documentation/BASICGuideTOC |ShowPrev...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;Data Sources&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/BASICGuideTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=EN/documentation/basic_guide/database_access_types&lt;br /&gt;
|NextPage=EN/documentation/basic_guide/database_access &lt;br /&gt;
|base=block&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
A database is incorporated into {{OOo}} by creating what is commonly referred to as a data source. The user interface provides a corresponding option for creating data sources in the Extras menu. You can also create data sources and work with them using {{OOo}} Basic.&lt;br /&gt;
&lt;br /&gt;
A database context object that is created using the &amp;lt;tt&amp;gt;createUnoService&amp;lt;/tt&amp;gt; function serves as the starting point for accessing a data source. This based on the &amp;lt;idl&amp;gt;com.sun.star.sdb.DatabaseContext&amp;lt;/idl&amp;gt; service and is the root object for all database operations.&lt;br /&gt;
&lt;br /&gt;
The following example shows how a database context can be created and then used to determine the names of all data sources available. It displays the names in a message box.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim DatabaseContext As Object&lt;br /&gt;
Dim Names&lt;br /&gt;
Dim I As Integer&lt;br /&gt;
&lt;br /&gt;
DatabaseContext = createUnoService(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Names = DatabaseContext.getElementNames()&lt;br /&gt;
&lt;br /&gt;
For I = 0 To UBound(Names())&lt;br /&gt;
  MsgBox Names(I)&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The individual data sources are based on the &amp;lt;idl&amp;gt;com.sun.star.sdb.DataSource&amp;lt;/idl&amp;gt; service and can be determined from the database context using the &amp;lt;tt&amp;gt;getByName&amp;lt;/tt&amp;gt; method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim DatabaseContext As Object&lt;br /&gt;
Dim DataSource As Object&lt;br /&gt;
&lt;br /&gt;
DatabaseContext = createUnoService(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;)&lt;br /&gt;
DataSource = DatabaseContext.getByName(&amp;quot;Customers&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example creates a &amp;lt;tt&amp;gt;DataSource&amp;lt;/tt&amp;gt; object for a data source called '''Customers'''.&lt;br /&gt;
&lt;br /&gt;
Data sources provide a range of properties, which in turn provide general information about the origin of the data and information about access methods. The properties are:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;Name (String)&amp;lt;/tt&amp;gt;:name of data source&lt;br /&gt;
;&amp;lt;tt&amp;gt;URL (String)&amp;lt;/tt&amp;gt;:URL of data source in the form of '''jdbc: subprotocol : subname''' or '''sdbc: subprotocol : subname'''&lt;br /&gt;
;&amp;lt;tt&amp;gt;Settings (Array)&amp;lt;/tt&amp;gt;:array containing &amp;lt;tt&amp;gt;PropertyValue&amp;lt;/tt&amp;gt;-pairs with connection parameters (usually at least user name and password)&lt;br /&gt;
;&amp;lt;tt&amp;gt;User (String)&amp;lt;/tt&amp;gt;:user name&lt;br /&gt;
;&amp;lt;tt&amp;gt;Password (String)&amp;lt;/tt&amp;gt;:user password (is not saved)&lt;br /&gt;
;&amp;lt;tt&amp;gt;IsPasswordRequired (Boolean)&amp;lt;/tt&amp;gt;:the password is needed and is interactively requested from user.&lt;br /&gt;
;&amp;lt;tt&amp;gt;IsReadOnly (Boolean)&amp;lt;/tt&amp;gt;:permits read-only access to the database&lt;br /&gt;
;&amp;lt;tt&amp;gt;NumberFormatsSupplier (Object)&amp;lt;/tt&amp;gt;:object containing the number formats available for the database (supports the &amp;lt;idl&amp;gt;com.sun.star.util.XNumberFormatsSupplier&amp;lt;/idl&amp;gt; interface)&lt;br /&gt;
;&amp;lt;tt&amp;gt;TableFilter (Array)&amp;lt;/tt&amp;gt;:list of table names to be displayed&lt;br /&gt;
;&amp;lt;tt&amp;gt;TableTypeFilter (Array)&amp;lt;/tt&amp;gt;:list of table types to be displayed. Values available are &amp;lt;tt&amp;gt;TABLE&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;VIEW&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;SYSTEM TABLE&amp;lt;/tt&amp;gt;&lt;br /&gt;
;&amp;lt;tt&amp;gt;SuppressVersionColumns (Boolean)&amp;lt;/tt&amp;gt;:suppresses the display of columns that are used for version administration&lt;br /&gt;
&lt;br /&gt;
{{Note|The data sources from {{OOo}} are not 1:1 comparable with the data sources in ODBC. Whereas an ODBC data source only covers information about the origin of the data, a data source in {{OOo}} also includes a range of information about how the data is displayed within the database windows of {{OOo}}.}}&lt;br /&gt;
&lt;br /&gt;
== Queries ==&lt;br /&gt;
&lt;br /&gt;
Predefined queries can be assigned to a data source. {{OOo}} notes the SQL commands of queries so that they are available at all times. Queries are used to simplify working with databases because they can be opened with a simple mouse click and also provide users without any knowledge of SQL with the option of issuing SQL commands.&lt;br /&gt;
&lt;br /&gt;
An object which supports the &amp;lt;idl&amp;gt;com.sun.star.sdb.QueryDefinition&amp;lt;/idl&amp;gt; service is concealed behind a query. The queries are accessed by means of the &amp;lt;tt&amp;gt;QueryDefinitions&amp;lt;/tt&amp;gt; method of the data source.&lt;br /&gt;
&lt;br /&gt;
The following example lists the names of data source queries can be established in a message box.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim DatabaseContext As Object&lt;br /&gt;
Dim DataSource As Object&lt;br /&gt;
Dim QueryDefinitions As Object&lt;br /&gt;
Dim QueryDefinition As Object&lt;br /&gt;
Dim I As Integer&lt;br /&gt;
&lt;br /&gt;
DatabaseContext = createUnoService(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;)&lt;br /&gt;
DataSource = DatabaseContext.getByName(&amp;quot;Customers&amp;quot;)&lt;br /&gt;
QueryDefinitions = DataSource.getQueryDefinitions()&lt;br /&gt;
&lt;br /&gt;
For I = 0 To QueryDefinitions.Count() - 1&lt;br /&gt;
  QueryDefinition = QueryDefinitions(I)&lt;br /&gt;
  MsgBox QueryDefinition.Name&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition to the Name property used in the example, the &amp;lt;idl&amp;gt;com.sun.star.sdb.QueryDefinition&amp;lt;/idl&amp;gt; provides a whole range of other properties. These are:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;Name (String)&amp;lt;/tt&amp;gt;:query name&lt;br /&gt;
;&amp;lt;tt&amp;gt;Command (String)&amp;lt;/tt&amp;gt;:SQL command (typically a &amp;lt;tt&amp;gt;SELECT&amp;lt;/tt&amp;gt; command)&lt;br /&gt;
&lt;br /&gt;
The following example shows how a query object can be created in a program-controlled manner and can be assigned to a data source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim DatabaseContext As Object&lt;br /&gt;
Dim DataSource As Object&lt;br /&gt;
Dim QueryDefinitions As Object&lt;br /&gt;
Dim QueryDefinition As Object&lt;br /&gt;
Dim I As Integer&lt;br /&gt;
&lt;br /&gt;
DatabaseContext = createUnoService(&amp;quot;com.sun.star.sdb.DatabaseContext&amp;quot;)&lt;br /&gt;
DataSource = DatabaseContext.getByName(&amp;quot;Customers&amp;quot;)&lt;br /&gt;
QueryDefinitions = DataSource.getQueryDefinitions()&lt;br /&gt;
QueryDefinition = createUnoService(&amp;quot;com.sun.star.sdb.QueryDefinition&amp;quot;)&lt;br /&gt;
QueryDefinition.Command = &amp;quot;SELECT * FROM Customer&amp;quot;&lt;br /&gt;
QueryDefinitions.insertByName(&amp;quot;NewQuery&amp;quot;, QueryDefinition)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The query object is first created using the &amp;lt;tt&amp;gt;createUnoService&amp;lt;/tt&amp;gt; call, then initialized, and then inserted into the &amp;lt;tt&amp;gt;QueryDefinitions&amp;lt;/tt&amp;gt; object by means of &amp;lt;tt&amp;gt;insertByName&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Sancho</name></author>
		
	</entry>
</feed>