Link to home
Start Free TrialLog in
Avatar of jules182
jules182

asked on

Problem with Data Link Proerties Dialog

Hi,

I'm implementing a Data Link Properties dialog in an app of mine.

The problem is, I'm probably getting a third of the (OLEDB) sources that are shown in the  Data Link dialog from VS2008 and other applications  (mainly Sql Server - no Access, Oracle etc.)

Has any body got any ideas what's wrong (I've been looking on the web for two days solid now) or any pointers to a solution.

Cheers,

Jules

Dim instance As DataLinksClass = New DataLinksClass
    Dim connection As New ConnectionClass
 
    If (instance.PromptNew = True) Then
 
      appSettings.ConnectionString = connection.ConnectionString
      appSettings.DataProvider = connection.Provider
 
      Dim startPos As Integer = connection.ConnectionString.IndexOf("Catalog=") + 8
      Dim endPos As Integer = InStr(startPos, connection.ConnectionString, ";") - 1
      Dim dbNameLength = endPos - startPos
      appSettings.DatabaseName = connection.ConnectionString.Substring( _
                                             startPos, dbNameLength)
      LoadScreen()
    End If
 
    connection = Nothing
    instance = Nothing

Open in new window

Avatar of wht1986
wht1986
Flag of United States of America image

i've used sql-dmo to get a list of servers in the past (its what the MS sql manager uses)

there's an example on code project
http://www.codeproject.com/KB/database/serverenum.aspx
you can also use the SqlDataSourceEnumerator

using System.Data;
using System.Data.Sql;

SqlDataSourceEnumerator servers = SqlDataSourceEnumerator.Instance;
DataTable serversTable = servers.GetDataSource();

foreach(DataRow row in serversTable.Rows)
{
string serverName = string.format(\"{0}\\\\{1}\", row[0], row[1];
// Add this to your list
}
sorry i had some syntax errors in that, here is the same that compiles

            SqlDataSourceEnumerator servers = SqlDataSourceEnumerator.Instance;
            DataTable serversTable = servers.GetDataSources();
            foreach(DataRow row in serversTable.Rows)
            {
                string serverName = string.Format("{0}\\\\{1}", row[0], row[1]);
            }
Avatar of jules182
jules182

ASKER

Hi wht1986,

Thanks for your answer, however it's not what I was looking for. I need to know why the OLEDB Data Link Properties is not showing all the data sources as VS2008 does on the same system.

Regards

Jules
Not the list of servers (see attached file)
DataLink.jpg
Ohhhhh,  heres a couple of quick links

previous response to a similar question
https://www.experts-exchange.com/questions/20617638/Enumerating-OLE-DB-Data-Link-Providers-ODBC-providers.html

example using OLEDB Providers Enumeration
http://www.advancode.com/articles.php?page=oledbproviders

another example that parses the registry
http://www.dotnet247.com/247reference/msgs/5/26311.aspx
Wht1986,

Thanks for all your input. However, I'm just trying to get the Data Link Properties box working the same as the Datalinks class in other applications on my PC. I don't want to rely on *.Udl files and I don't want to redevelop this dialog.

Below is the full list (Data Links Dialog) from another app.

Could I be missing an import in my project references?

Regards,

Jules
Datalink2.jpg
Oh, you just want to display the built in dialog box?

I think this link might help
http://support.microsoft.com/kb/286189
Hi,

Sorry to take so long to get back to you. Tried that as well but still only shows the subset of OLEDB providers as above.

Cheers

Jules
Sorry that is all I know regarding showing the built in dialog.  If you want to build your own and scan through the registry keys, I can help you with doing that.
Hi wht1986,

That sounds good. If you wouldn't mind posting an example.

Thanks once again for all your help.

Cheers,

Jules
ASKER CERTIFIED SOLUTION
Avatar of wht1986
wht1986
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much for your help. It sames the problem lies with XP Pro x64. You have to give different registry keys. Back to the drawing board....................