1. Joseph Vendra
  2. PowerBuilder
  3. Thursday, 11 November 2021 22:22 PM UTC

Anyone have a reliable way to get a list of SQL Servers using PowerBuilder 2021?

Either as native PowerBuilder PowerScript code, possibly by using odbc32.dll or NetServerEnumerate api function calls or perhaps another way?

I need to be able to populate a listbox with a list of servers or computers running any instance of SQL Server, standard, enterprise, SQL Express engines

From there ideally next would be to get a list of the databases under that server, assuming the user was able to provide a SQL ID/Password to authenticate to the server.

The PB Application would be an application running on Windows 10 normally (Possibly older Windows OS flavors but the target is Windows 10+)

Any suggestions or help is greatly appreciated.

Joseph

Joseph Vendra Accepted Answer Pending Moderation
  1. Friday, 12 November 2021 07:38 AM UTC
  2. PowerBuilder
  3. # 1

Well thanks for the response but I did not see any actual netserverenumerate function in that example ,

When examined, its a great set of functions which do a variety of other things that could be useful later, but doesn't appear that OdbcAPI set of functions can do any assessment of the network or browse other computers to determine if they are running MS SQL Server instances or not.

In the usage intended:

1) There are no data sources defined yet therefore listing datasources is not enough
2) There is always a SQL Server instance because if there was none, the process intended should not continue because the prerequisite steps were not followed or completed properly
3) The solution needs to be as dependable as possible in the detection of only MS SQL Server instances, but its not the only option because if the user knew the NETBIOS or IP address for the SQL server they could key it directly into a sle control and click connect/verify and the app would just go out and verify that a transaction object could contact that server but the point of this exercise was 'discovery' to help those less fortunate and to try and be kind and populate a drop down for the users directly more of as a courtesy.

Solution that seems promising:

Build a small c# .net core based dll in snapdevelop and using PB 2021 .net import routine imported it into PB and instantiated the nvo it generated, the c# sql location routine appears to be working reliably so in my opinion this task is now complete, on the surface this appears viable.

It does find my primary SQL sever so I will have to see if it can find SQL Express engines running.

Honestly, to my mind its a bit rough, would have preferred to be able to have all the functionality in PB but I just couldn't get the netserverenumerate function to work properly within pb, at least not on my windows 10 machines, something might have changed or such that would have to be addressed before it works like it should, or i just got some function declarations wrong or whatever, ...

 

Joseph

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 12 November 2021 03:15 AM UTC
  2. PowerBuilder
  3. # 2

I have an ODBC API example that includes listing data sources.

https://www.topwizprogramming.com/freecode_odbcapi.html

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.