WiX Toolset - How to determine the SQL Server DATA path - sql-server

I've tried to do this a few ways. Here's my latest attempt, which does not work, but should help illustrate what I'm looking to do.
Note: My assumption for the GetSQLServerInstalledInstance Id is that it will return one instance.
My goal is to find the DATA directory path for an instance of SQL Server installed on the machine that will also be installing my companies product.
<util:RegistrySearch Id='GetSQLServerInstalledInstance'
Variable='SQL_SERVER_INSTALLED_INSTANCE'
Root='HKLM'
Key='SOFTWARE\Microsoft\Microsoft SQL Server'
Value="InstalledInstances"
Format="raw" />
<util:RegistrySearch Id='GetSQLServerInstalledInstanceName'
Variable='SQL_SERVER_INSTALLED_INSTANCE_NAME'
Root='HKLM'
Key='SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL'
Value="[SQL_SERVER_INSTALLED_INSTANCE]"
Format="raw"
After="GetSQLServerInstalledInstance" />
<util:RegistrySearch Id='GetSQLServerInstallPath'
Variable='SQL_SERVER_INSTALL_PATH'
Root='HKLM'
Key='SOFTWARE\Microsoft\Microsoft SQL Server\[SQL_SERVER_INSTALLED_INSTANCE_NAME]\Setup'
Value="SQLPath"
Format="raw"
After="GetSQLServerInstalledInstanceName" />
<SetProperty Id='SQL_SERVER_FILE_PATH' Value="[SQL_SERVER_INSTALL_PATH]\DATA" After="CostFinalize" Sequence="first" />
In the end, I'm looking for the SQL_SERVER_FILE_PATH property to contain this path. (e.g. C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA)
It's also important that the calls are sequenced at that subsequent calls can contain information derived from previous calls.
I'm still fairly new to WiX, but I could imagine how to do this pretty easily if the SetProperty element allowed a RegistrySearch child element to set it's value. Can this be handled by a sequence of CustomActions that would act similar to a SetProperty element that allows a RegistrySearch child element to set it's value?
Thanks

I found a simpler method for determining the SQL Server DATA directory path using WiX. For future reference, this was how I solved this:
<Property Id='SQL_SERVER_INSTALL_PATH'>
<RegistrySearch Id='GetSQLServerInstallPath' Root='HKLM'
Key='SOFTWARE\Microsoft\MSSQLServer\Setup'
Name='SQLPath' Type='directory' Win64="yes" />
</Property>
<SetProperty Id='SQL_SERVER_DATA_PATH' Value="[SQL_SERVER_INSTALL_PATH]DATA" After="CostFinalize" Sequence="first" />
Hope this helps others

Related

Fuse ESB/OSGI/Blueprint reading configuration files alphabetically?

I experience something rather strange and I would like to know if other people have experienced the same...
I am currently working on a project using jboss fuse (previously fuse esb) and we are using blueprint for our configuration files.
We use property place holders and have the following files under src/main/resources/OSGI-INF/blueprint:
blueprint.xml
properties.xml
In blueprint.xml we have something like this:
<bean id="myBean" class="com.test.MyClass">
<property name="prop1" value="${my.prop}" />
<∕bean>
Then in properties.xml I have this:
<cm:property-placeholder persistent-id="my.properties" update-strategy="reload">
<cm:default-properties>
<cm:property name="my.prop" value="true" />
</cm:default-properties>
</cm:property-placeholder>
And I obviously have a setter for prop1 (which is a String) in MyClass.
But what I see is that when I deploy this, prop1 is set to "${my.prop}" instead of "true", i.e the variable never gets replaced with its defined value!
But now if I call the properties file aaa_properties.xml, it works!!
Is this a bug in the blueprint container?
Did any one else experience the same behaviour?
Thanks for your feedback :)
JM.
I found some information about Blueprint Configuration in Fuse ESB
It states:
If you need to place your blueprint configuration files in a non-standard location (that is, somewhere other than OSGI-INF/blueprint/*.xml), you can specify a comma-separated list of alternative locations in the Bundle-Blueprint header in the manifest
For Example:
Bundle-Blueprint: lib/account.xml, security.bp, cnf/*.xml
I suggest, can you please give this a try, and specify your xml files here, naturally in the correct ordering.

WiX: Installing to Multiple DB Targets

I have a set of DB scripts that I need to run during install. I have a UI screen that the user can select the server, provide credentials, and then select the target database. What I need to do is install the bulk of the scripts to the target database the user selected but some scripts need to go to the Master DB. I've tried searching the net for answers but I haven't really found anything that tells me how to do that. If someone has an article or suggestion on how this is accomplished, I would appreciate a little help.
Thanks
You can declare two SqlDatabase nodes, one for each database where the scripts have to be run:
<Binary Id="SqlScriptBinary1" SourceFile="script1.sql" />
<Binary Id="SqlScriptBinary2" SourceFile="script2.sql" />
<Component Id='SqlComponent.Sql1' Guid='YOUR-GUID-HERE' KeyPath='yes'>
<sql:SqlDatabase Id='Database1' Database='[DATABASE_NAME1]' Server='[DATABASE_SERVER]'
CreateOnInstall='no'
DropOnInstall='no' DropOnReinstall='no' DropOnUninstall='no'
ContinueOnError='no'>
<sql:SqlScript Id='SqlScript1' BinaryKey='SqlScriptBinary1' ExecuteOnInstall='yes' />
</sql:SqlDatabase>
</Component>
<Component Id='SqlComponent.Sql2' Guid='YOUR-GUID-HERE' KeyPath='yes'>
<sql:SqlDatabase Id='Database2' Database='[DATABASE_NAME2]' Server='[DATABASE_SERVER]' CreateOnInstall='no'
DropOnUninstall='no' DropOnInstall='no' DropOnReinstall='no' ContinueOnError='no'>
<sql:SqlScript Id='SqlScript2' BinaryKey='SqlScriptBinary2' ExecuteOnInstall='yes' />
</sql:SqlDatabase>
</Component>
Do a quick search and you'll find articles that may help you, such as this one for example.

Drop database from WiX installer

The properties [DATABASE_NAME] and [SERVER_NAME] are defined by the user at installation and it seems like unless they are hard coded then doing this fails:
<Component Id="Component.Sql.Database" Guid="*">
<sql:SqlDatabase
Id="Sql.Database"
Database="[DATABASE_NAME]"
Server="[SERVER_NAME]"
CreateOnInstall="yes"
DropOnUninstall="yes"
ContinueOnError="no"
ConfirmOverwrite="yes" />
</Component>
The bit that is supposed to drop the db is DropOnUninstall="yes"
I've found a post on the WiX user group suggesting the following approach to dropping the database on uninstall:
<Component Id="Component.Sql.DropDatabase" Guid="146CD264-1F6D-4E19-BFCC-E544F5BD2D6C">
<sql:SqlString
Id="Sql.DropDatabase"
SqlDb="Sql.Master"
Sequence="1000"
ExecuteOnInstall="no"
ExecuteOnUninstall="yes"
ExecuteOnReinstall="no"
ContinueOnError="no"
SQL="DROP DATABASE [\[][DATABASE_NAME]\[]]"/>
</Component>
<Fragment>
<sql:SqlDatabase Id="Sql.Master" Database="master" Server="[SERVER_NAME]" />
</Fragment>
The idea being that at uninstall the DROP DATABASE ... command is executed on the master database on the server. However this SQL statement never gets executed on the server.
The MSIEXEC log doesn't seem to give any information and I get no errors.
Has anyone successfully achieved this (before I write a custom action to do this)?
I've tried copying the database name and server to the registry to cache them, but this hasn't helped.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" <!-- Need to import this -->
xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension"><!-- Need to import this -->
<sql:SqlDatabase Id="SqlDatabase"
Database="TestDatabase"
Server="[SQLSERVER]"
DropOnUninstall="yes"
User="SQLUser">
This will definitely work.....

SSRS ReportViewer problems with XML embedded data source

I have C# (WPF) application where I want to display a SSRS report in the ReportViewer control. The local report file has XML datasource embedded in it. The report is displayed correctly when running from SQL Server Business Intelligence Development Studio. But when I run with my app I get the following error:
A data source instance has not been supplied for the data source '...'.
So here is what I'm doing:
I have defined embedded XML data, as explained in this tutorial Defining a Report Dataset from Embedded XML Data. I have a data source called XmlDataSource_TopCustomers and a data set called XmlDataSet_TopCustomers, using that data source. I have referred the data set in a table and a chart. Overall, the RDL looks like this (just the essential, of course):
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<Body>
<ReportItems>
<Tablix Name="Tablix1">
<DataSetName>XmlDataSet_TopCustomers</DataSetName>
</Tablix>
<Chart Name="Chart1">
<DataSetName>XmlDataSet_TopCustomers</DataSetName>
</Chart>
</ReportItems>
</Body>
<DataSources>
<DataSource Name="XmlDataSource_TopCustomers">
<ConnectionProperties>
<DataProvider>XML</DataProvider>
<ConnectString />
</ConnectionProperties>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>47833b52-231f-4634-8af4-3c63272b02a7</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="XmlDataSet_TopCustomers">
<Query>
<DataSourceName>XmlDataSource_TopCustomers</DataSourceName>
<CommandText><Query>
<ElementPath>Root /CustomerOrder {#CustomerNo, #CustomerName, #OrdersCount (Integer), #Total(Float), #AveragePerOrder(Float)}</ElementPath>
<XmlData>
<Root>
<CustomerOrder CustomerNo="10001" CustomerName="Name 1" OrdersCount="2" Total="5.446740000000000e+003" AveragePerOrder="2.723370000000000e+003" />
<CustomerOrder CustomerNo="10894" CustomerName="Name 2" OrdersCount="5" Total="3.334750000000000e+003" AveragePerOrder="6.669500000000001e+002" />
<CustomerOrder CustomerNo="12980" CustomerName="Name 3" OrdersCount="2" Total="2.003290000000000e+003" AveragePerOrder="1.001645000000000e+003" />
</Root>
</XmlData>
</Query></CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<Fields>...
</DataSets>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>02172db8-2a1d-4c35-9555-b37ee6193544</rd:ReportID>
</Report>
At this point everything works fine from the IDE.
In my C# application, I have a ReportViewer and the following code:
Viewer.LocalReport.ReportPath = #"<actualpath>\TopCustomers.rdl"; // actual path is OK
Viewer.RefreshReport();
And then I get that
A data source instance has not been supplied for the data source 'XmlDataSet_TopCustomers'.
I've seen others having the same problem, but in most of the cases the problem is multiple datasources, which is not the case here, as you can see from the RDL snippet above.
Any suggestions?
The answer to my question can also be found here When to use RDLC over RDL reports? and here http://www.gotreportviewer.com/. It's basically this:
Unlike the Report Server the ReportViewer control does not connect to
databases or execute queries. Also, in local mode the only export
formats available are Excel, Word and PDF. (In remote mode all formats
supported by the Report Server are available.) The ReportViewer
control cannot be extended by adding custom renderers or custom report
items.
More information can be found here http://msdn.microsoft.com/en-us/library/ms252109(v=vs.80).aspx.
The ReportViewer control, which processes .rdlc files, ignores the
element of RDL. If a report definition contains a query, the
control will not process it.
and
When converting a .rdl file to .rdlc format, you must manually replace
the data source and query information in the report definition with
data constructs provided in your application
So you have to fetch the data explicitly and provided for the ReportViewer as a ReportDataSource having the exact same name as the dataset in the RDL file.
I have a small command line app that does something similar, but between defining the report path and doing anything with the report viewer I'm setting a data source for the report to be run against:
report.DataSources.Add(new ReportDataSource("DataSet_for_Distribution", table));
...table is a DataTable.
After that I have no problems programmatically calling the report Render method.
Can you set a break before the render and see what data sources the report actually has?
Another thing to try, and it may just be that you formatted (or stack formatted ) it to post it here, but when I embed an XML data set in a report it is all using a format like this:
<CommandText><Query>
<ElementPath>Root /S {#OrderDate (Date), #TotalDue (Decimal)} /C {#LastName} </ElementPath>
<XmlData>
<Root>
<S OrderDate="2003-07-01T00:00:00" SalesOrderNumber="SO51131" TotalDue="247913.9138">
<C FirstName="Shu" LastName="Ito" />
</S>
<S OrderDate="2003-10-01T00:00:00" SalesOrderNumber="SO55282" TotalDue="227737.7215">
<C FirstName="Shu" LastName="Ito" />
</S>
<S OrderDate="2002-07-01T00:00:00" SalesOrderNumber="SO46616" TotalDue="207058.3754">
<C FirstName="Jae" LastName="Pak" />
</S>
<S OrderDate="2002-08-01T00:00:00" SalesOrderNumber="SO46981" TotalDue="201490.4144">
<C FirstName="Ranjit" LastName="Varkey Chudukatil" />
</S>
<S OrderDate="2002-09-01T00:00:00" SalesOrderNumber="SO47395" TotalDue="198628.3054">
<C FirstName="Michael" LastName="Blythe" />
</S>
</Root>
</XmlData>
</Query></CommandText>
I am not sure from what you have stated if the data source has specified credentials.
This part here:
<ConnectionProperties>
<DataProvider>XML</DataProvider>
<ConnectString />
</ConnectionProperties>
Generally speaking with SQL data sources when reports fail to view for others or from applications it is due to the hosting server assuming a different credential than your IDE building the application. It does not know if my name is Brett, that my credentials are running it when calling it remotely. When you specify the credentials on the server hosting the report you can usually get around this. You go into the server hosting the report, I assume you are doing this as you have an 'rdl' report versus an rdlc report. Find the datasource, click properties, change setting to be 'use these credentials'. Supply credentials that you know work.
This may fix the issue. I am not certain with Sharepoint connections and XML connections but this is common with viewing issues with SQL Server connections.

iBatis - Why is sqlMapConfig.xml unable to find the sql maps defined in it?

I have a sqlMapConfig.xml that has three SQLMaps defined in it.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<!-- Statement namespaces are required for Ibator -->
<settings enhancementEnabled="true" useStatementNamespaces="true"/>
<!-- Setup the transaction manager and data source that are
appropriate for your environment
-->
<transactionManager type="JDBC">
<dataSource type="SIMPLE" >
<property name="JDBC.Driver"
value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:mysql://localhost:3306/sug"/>
<property name="JDBC.Username"
value="root"/>
<property name="JDBC.Password"
value="admin"/>
</dataSource>
</transactionManager>
<!-- SQL Map XML files should be listed here -->
<sqlMap resource="com/tatakelabs/dbmaps/categories_SqlMap.xml" />
<sqlMap resource="com/tatakelabs/dbmaps/pro_SqlMap.xml" />
<sqlMap resource="com/tatakelabs/dbmaps/pro_category_SqlMap.xml" />
</sqlMapConfig>
I get a runtime error - Cause: java.io.IOException: Could not find resource com/tatakelabs/dbmaps/categories_SqlMap.xml
categories_SqlMap.xml is present in that location. I tried changing the location of the map xml, but that did not help. sqlMapConfig.xml validates against the DTD. categories_SqlMap.xml also validates against the right DTD. I am at my wits end trying to figure out why it can't find the resource. The sqlMap files are generated by iBator.
This was happening because the sqlmap file location was not getting copied to target. Added a copy goal and that fixed it.
I had the same problem. It appears the problem lies with the location of the config file. Thus, its in relation of the project resource structure.
I moved the config file in the same package as the mapper classes and it worked. In this case try moving all the resources to this package and update the resource attributes to:
<sqlMap resource="categories_SqlMap.xml" />
<sqlMap resource="pro_SqlMap.xml" />
<sqlMap resource="pro_category_SqlMap.xml" />
Solved it.
I moved the xml file to where the Pojo was located and provided the path as follows:
<sqlMap resource="com/heena/ibatis/model/jsr/jsr.xml" />
And it worked.
place it ...src\java\abc.xml under the Source Packages directory.
If you are using Spring, you can use a SqlMapClientFactoryBean specifying property "mappingLocations". In this property you can specify a generic path, such as "com/tatakelabs/dbmaps/*_SqlMap.xml" or with a variable such as ${mapfiles}, that will be resolved by Spring as an array of file names. This lets you omit sqlMap element in sqlMapConfig. This technique will run with iBatis 2.3.4 on. However sql-map-config-2.dtd is also contained inside iBatis.jar, so you can experience some parsing errors, as /com/ibatis/sqlmap/engine/builder/xml/sql-map-config-2.dtd may have a bug. In this case you may want to replace it inside the jar with the one from the URL:
http://ibatis.apache.org/dtd/sql-map-config-2.dtd.

Resources