473,811 Members | 2,971 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 8980
ODBC DSN's? You can read the registry under HKLM\Software\O DBC\ODBC.INI...

"abcd" <ab**@abcd.co m> wrote in message
news:e$******** ******@tk2msftn gp13.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.co m> wrote in message
news:e$******** ******@tk2msftn gp13.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.Co llections.Sorte dList"></seealso>
public static SortedList listAllDSN()
{
SortedList allDSN = new SortedList();

// Get User DNS Names
RegistryKey reg = (Registry.Curre ntUser).OpenSub Key("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_REGI STRY.
foreach ( string s in reg.GetValueNam es() )
{
allDSN.Add( s , null );
}
}
try
{
reg.Close();
}
catch ( System.Exceptio n ex )
{
}

// Get System DNS Names
reg = (Registry.Local Machine).OpenSu bKey("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_REGI STRY.
foreach ( string s in reg.GetValueNam es() )
{
try
{
allDSN.Add( s , null );
}
catch ( System.Exceptio n ex )
{
}
}
}
try
{
reg.Close();
}
catch ( System.Exceptio n 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
5264
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 structures? Thanks for any hints, Leszek Taratuta
0
1154
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 content area, and the data bound controls are in the second. The data bound controls are having a problem seeing the data sources at run time (even though everything is picked up by the visual studio at design time). I get an error message...
1
2756
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 Sources window ... ( means expandable, means expanded, is a checked checkbox, "QmsDataLayer" is the name of the referenced data layer.)
0
1409
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 You display the Data Sources window by clicking Show Data Sources on the Data menu. The Data menu is only available when a project is open in Visual Studio.
10
1542
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 of the database components. Yet, when I switch to code view, I can see everything just fine. Does anyone have any idea why the Data Sources window becomes disabled when I'm viewing forms? TIA.
0
840
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 with an business object class? many thanks
0
3132
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 datasets in App_Code folders throughout the project) to behave consistently. Sometimes data source are displayed, sometimes not. Sometimes I can add new data sources, sometimes I can't. Some classes are displayed, some aren't. I can't figure...
3
7726
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 the following error below. I would appreciate any insight, direction or help regarding this. Thank-you!! Walid
0
1055
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 learn about using Data Sources. My requirements are pretty simple, the underlying data in the SQL database is modified from outside sources or triggers I wrote in the DB. For the purpose of this question, all I realy want to do is display in...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10389
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.