473,505 Members | 15,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8965
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
5210
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
1135
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
2736
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
1387
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
1511
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
817
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
3107
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
7705
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
1046
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
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
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
5614
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,...
1
5035
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...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.