473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

data sources using C#

I want to get the list of data sources on the server machine using C# and
ASP.NET
any clues how to get that...I have done this using VB using SQLDataSources
function from ODBC32.dll

thanks
Nov 17 '05 #1
3 8955
ODBC DSN's? You can read the registry under HKLM\Software\ODBC\ODBC.INI...

"abcd" <ab**@abcd.com> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
I want to get the list of data sources on the server machine using C# and
ASP.NET
any clues how to get that...I have done this using VB using
SQLDataSources
function from ODBC32.dll

thanks

Nov 17 '05 #2
Hi,

I don;t know of any managed way of doing that , but you can p/invoke it.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"abcd" <ab**@abcd.com> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
I want to get the list of data sources on the server machine using C# and
ASP.NET
any clues how to get that...I have done this using VB using
SQLDataSources
function from ODBC32.dll

thanks

Nov 17 '05 #3
Here is the code that I use to get a SortedList of all the DSN names
from the registry...

<code>
/// <summary>
/// Reads the local user/system DSN registry entries and returns a
SortedList of Data Source Names.
/// </summary>
/// <remarks>In the event that a DSN exists in both the User and System
registries,
/// the User DSN takes precedence over the System DSN.</remarks>
/// <returns>The SortedList of Data Source Names</returns>
/// <seealso cref="System.Collections.SortedList"></seealso>
public static SortedList listAllDSN()
{
SortedList allDSN = new SortedList();

// Get User DNS Names
RegistryKey reg = (Registry.CurrentUser).OpenSubKey("Software");
reg = reg.OpenSubKey("ODBC");
reg = reg.OpenSubKey("ODBC.INI");
reg = reg.OpenSubKey("ODBC Data Sources");

if (reg != null)
{
// Get all DSN entries defined in DSN_LOC_IN_REGISTRY.
foreach ( string s in reg.GetValueNames() )
{
allDSN.Add( s , null );
}
}
try
{
reg.Close();
}
catch ( System.Exception ex )
{
}

// Get System DNS Names
reg = (Registry.LocalMachine).OpenSubKey("Software");
reg = reg.OpenSubKey("ODBC");
reg = reg.OpenSubKey("ODBC.INI");
reg = reg.OpenSubKey("ODBC Data Sources");

if (reg != null)
{
// Get all DSN entries defined in DSN_LOC_IN_REGISTRY.
foreach ( string s in reg.GetValueNames() )
{
try
{
allDSN.Add( s , null );
}
catch ( System.Exception ex )
{
}
}
}
try
{
reg.Close();
}
catch ( System.Exception ex )
{
}

return allDSN ;
}
</code>

Joel

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
0
by: Mafuba | last post by:
I'm trying to use data sources with data bound controls on one of my pages that's using a master page. The master page has 2 ContentPlaceHolders, and in my page the data sources are in the first...
1
by: dbuchanan | last post by:
Hello, A section in Data Sources window is mystifying to me. In the case of my code the Data Sources window shows my references to the data access layer. First here is what I see in my Data...
0
by: GS | last post by:
Documentation states that there supposed to be a "Data Sources" windows in VS 2005. See below. I can not find Data menu in VS 2005 anywhere. Anybody sees that menu? Opening the Data Sources Window...
10
by: David Lee Conley | last post by:
When I open the Data Sources window and create a new data source, everything works fine. But if I have a form showing in the IDE, the Data Sources window becomes disabled and doesn't display any...
0
by: Annie | last post by:
hello guys, Is there any good example of using object data sources using asp.net source. I am looking for any example, any onle resource that exaplains in details all the details of using it...
0
by: BillE | last post by:
I am using Visual Studio 2005 to create a web site which includes reports. The web site has several sub-folders. When working with reports I can't get the website data sources (classes and...
3
by: =?Utf-8?B?V2FsaWQ=?= | last post by:
Hello: I have migrated a site from IIS5 to IIS6. The site is configured and the we app is installed on the new IIS site. I can get to the web page but when I try to login, this is what I get...
0
by: Edwin Elston | last post by:
I'm new with Data Sources and am using VB.Net in VS2005, although I have VS2010 available if it matters. In previous code I just wrote queries using OleDbConnections and OleDbCommands but wanted to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.