Hello,
I need to check if a given sql server instance already exists on the local machine.
Since I already needed the list of available servers elsewhere, my first approach was to check if the string containing the available instances contains the requested instance name. Failed. The string contained the name, but the function returned false.
Next approach: Splitting the string containing the names by $NEWLINE$ and check if the collection contains the requested name: Failed.
Next one: Replace all occurences of $NEWLINE$ with µ... a character most probable not used for an instance name and checking... Failed.
Next try: Set variable $SERVICENAME$ to MSSQL$$MYREQUESTEDINSTANCENAME$ and checking if this service runs on the local machine... failed.
Since the instance could be sql2008 as well as sql2005 I cannot simply check the registry for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\InstalledInstances or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL because sql 2005 instances are not listed there.
The desired usage: A user should be able to provide a name for a new sql server instance. The Next button of this wizard step should be disabled when an instance with the provided name already exists.
Suggestions?
Thanks in advance!
EDIT: I got the service approach working. How can I utilize the result to enable/disable the NEXT button depending on the content of a textbox being an instance?
For example: An instance with the name MYINSTANCE exists on the server. When the user types MYINST the Next button should be enabled... when he types MYINSTANCE it should change to disabled, when he continues and types MYINSTANCEX it should be enabled again.
Check if SQL instance exists
-
FrancescoT
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Check if SQL instance exists
Dear Anja,
If I have not missed your question, I suppose that a possible way to verify if a given Instance Name is available, with a possible Instance Name list, this could be managed as follow:
The same as above in Human readable format:
With the above rules, I am supposing that the string to test must be NOT EQUAL to "MYTEXT" in order to have NEXT button enabled.
Hope this helps you.
If I have not missed your question, I suppose that a possible way to verify if a given Instance Name is available, with a possible Instance Name list, this could be managed as follow:
Code: Select all
~InstallAware Clipboard Data~
~End~
~{E613137F-315A-4978-9778-D0A4743B2587}~
~MessageBox~
~{20541779-815E-4469-9C56-1DD06501BD72}~
~Debug~
~Found Instance $MSSQLINSTANCE_NAME$.~
~0~
~1~
~~
~If~
~{DE17399E-6A75-4D00-9B79-6E2B2330CB86}~
~MSQLINSTANCE_FOUND~
~0~
~TRUE~
~FALSE~
~Comment~
~{1E5519F6-BE43-43F3-8F80-D0CFAB5A7ED1}~
~~
~Next~
~{A11DC6F6-7573-4C38-9C44-1C7AABBC7ACA}~
~End~
~{6112C75B-AF01-481E-AE11-5733835C034C}~
~Break~
~{B94F3BA4-205B-44D1-9DFF-7094F1E365A8}~
~Set Variable~
~{054559BB-AE19-4BA3-AEC6-0CA4C267876B}~
~MSQLINSTANCE_FOUND$MYAH$MYAH$FALSE~
~TRUE~
~If~
~{00682B60-CDD3-4A9B-A9D9-4E74169846EC}~
~ELEMENT~
~0~
~$MSSQLINSTANCE_NAME$~
~FALSE~
~For Each~
~{F9A8A5BC-6340-4928-A045-102FDC4DEB0B}~
~ELEMENT~
~$NEWLINE$~
~$MSSQL_INSTANCES$~
~Comment~
~{F75332F1-6DA9-442C-BFAA-0D5E458A6451}~
~~
~Set Variable~
~{D7D94A01-5510-48C9-8235-D7DB9B51ADC5}~
~MSQLINSTANCE_FOUND$MYAH$MYAH$FALSE~
~FALSE~
~Set Variable~
~{F8D6C265-DAFC-424A-BD2A-3081B34C1650}~
~MSSQLINSTANCE_NAME$MYAH$MYAH$FALSE~
~MYSQL3~
~Set Variable~
~{635C5302-BA7A-470E-A1C9-2F8DF2E905E8}~
~MSSQL_INSTANCES$MYAH$MYAH$FALSE~
~MYSQL1$NEWLINE$MYSQL2$NEWLINE$MYSQL3$NEWLINE$MYSQL4~
Code: Select all
Set Variable MSSQL_INSTANCES to MYSQL1$NEWLINE$MYSQL2$NEWLINE$MYSQL3$NEWLINE$MYSQL4
Set Variable MSSQLINSTANCE_NAME to MYSQL3
Set Variable MSQLINSTANCE_FOUND to FALSE
for each Element ELEMENT in $NEWLINE$ delimited Collection of $MSSQL_INSTANCES$ do
if Variable ELEMENT Equals $MSSQLINSTANCE_NAME$
Set Variable MSQLINSTANCE_FOUND to TRUE
Break out of Loop
end
next
if Variable MSQLINSTANCE_FOUND Equals TRUE
MessageBox: Debug, Found Instance $MSSQLINSTANCE_NAME$.
end
This should be easly resolved using the following Dialog Object behaviors Rules;EDIT: I got the service approach working. How can I utilize the result to enable/disable the NEXT button depending on the content of a textbox being an instance?
Code: Select all
IF (Edit1.Text = MYTEXT) THEN Next.Enabled := FALSE;
IF (Edit1.Text <> MYTEXT) THEN Next.Enabled := TRUE;Hope this helps you.
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
-
anja_laenge
- Posts: 131
- Joined: Tue Nov 20, 2012 1:02 am
Re: Check if SQL instance exists
Dear Francesco,
The service approach mentioned above can only give it's result to a variable, your approach would report to a variable as well.
A nice way would be to put the functionality inside a method or function an evaluate this inside the .miaf-rules... something like
I need to access the result each time the value of edit1.Text changes, so it would be no use to enter the dialog with a list of existing instances because I could not react to a change of the edit1.Text.
this question was meant differently: I want to use the result of the sql instance search in the object behaviour rules.FrancescoT wrote:This should be easly resolved using the following Dialog Object behaviors Rules;EDIT: I got the service approach working. How can I utilize the result to enable/disable the NEXT button depending on the content of a textbox being an instance?With the above rules, I am supposing that the string to test must be NOT EQUAL to "MYTEXT" in order to have NEXT button enabled.Code: Select all
IF (Edit1.Text = MYTEXT) THEN Next.Enabled := FALSE; IF (Edit1.Text <> MYTEXT) THEN Next.Enabled := TRUE;
The service approach mentioned above can only give it's result to a variable, your approach would report to a variable as well.
A nice way would be to put the functionality inside a method or function an evaluate this inside the .miaf-rules... something like
Code: Select all
IF (CheckInstance(Edit1.Text) <> NOTINSTALLED) THEN Next.Enabled := TRUE;-
FrancescoT
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Check if SQL instance exists
Dear Anja,
If you want you could follow an approach similar to the one I described with the following topic;
http://www.installaware.com/forum/viewt ... f=2&t=9319
Of course, the above method suppose that a button should be pressed to start the verification and conseguently, the NEXT button should be updated based on the result of this verification.
Unfortunately, it is not possible to include a function call with the Dialog Rule but of course, you can execute any kind of functions (... even an external one from a DLL) with a Dialog button action.
Hope this helps you.
Regards
If you want you could follow an approach similar to the one I described with the following topic;
http://www.installaware.com/forum/viewt ... f=2&t=9319
Of course, the above method suppose that a button should be pressed to start the verification and conseguently, the NEXT button should be updated based on the result of this verification.
Unfortunately, it is not possible to include a function call with the Dialog Rule but of course, you can execute any kind of functions (... even an external one from a DLL) with a Dialog button action.
Hope this helps you.
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

