class library project using ado.net

 Hi ,

How are you?

I plan to develop a .net class library project that can create a dll file after I build it.

I want to use the database functions in the project. so I need to use ADO.NET

I use ado.net for .net web application before and I save the connection string to web.config.

but that is different for class library application and I do not have web.config now.

My question are here.

1.which file I can use to save connection string for class library app

2.how to develop database application in class library project.

Do you have a simple demo code? so I can get the idea quickly.

 

Thanks

 

Mark 

 

 

 

0
marks416
7/16/2008 2:27:51 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

5 Replies
898 Views

Similar Articles

[PageSpeed] 57

 A class library will always be used by another application (web application, a windows application, a console application etc)

The connection information will be provided by the application that is using the class library. In case of a web application it will be through the web.config and for other it would be app.config

When you are developing the library, you would have some sort of test application using the class library. You need to specify the connection information in your test application.


Regards,
Prashant


Dont forget to click "Mark as Answer" on the post that helped you.
0
Prashant
7/16/2008 2:49:08 PM

Hi,

Thank you for reply.

I develop the dll for a flex RIA app. I need hard code the connection string in dll.

I see a app.config file and I save the connection string there like

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

<section name="pizzatest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

</sectionGroup>

</configSections>

<applicationSettings>

<pizzatest.Properties.Settings>

<setting name="conn" serializeAs="String">

<value>**************************************************************</value>

</setting>

</pizzatest.Properties.Settings>

</applicationSettings>

</configuration>

Please let me know how to get the string "conn" in other cs classes.

 

Thanks

 

Mark

 

 

 

0
marks416
7/16/2008 4:47:06 PM

Hi,

Thank you for reply.

I develop the dll for a flex RIA app. I need hard code the connection string in dll.

I see a app.config file and I save the connection string there like

<?xml version="1.0" encoding="utf-8" ?>

<configuration><configSections>

<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

<section name="pizzatest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

</sectionGroup>

</configSections>

<applicationSettings>

<pizzatest.Properties.Settings>

<setting name="conn" serializeAs="String">

<value>**************************************************************</value>

</setting>

</pizzatest.Properties.Settings> </applicationSettings>

</configuration>

Please let me know how to get the string "conn" in other cs classes.

 

Thanks

 

Mark

 

 

 

0
marks416
7/16/2008 4:48:32 PM

But I check the web.config and the connection strion is like

<connectionStrings>
        <add name="TEV3ConnectionString1" connectionString="Data Source=USER-2A39ACF084\SQLEXPRESS;Initial Catalog=TEV3;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

I do not have idea to save this in app.config. maybe I have to hard code it in class.

 

Thanks

Mark

0
marks416
7/16/2008 4:59:02 PM

Hi marks416,

If you want to stored the connection string in the “app.config”, you may retrieve it by using the “XmlDocument”.

using System.Xml;

public string ConnectionString()
{
    XmlDocument xDoc = new XmlDocument();
    try
    {
        xDoc.Load(@"C:\Users\XXX\Documents\Visual Studio 2008\Projects\ClassLibrary1\ClassLibrary1\App.config");
        XmlNode xNode;
        xNode = xDoc.SelectSingleNode("//applicationSettings").SelectSingleNode("//pizzatest.Properties.Settings").SelectSingleNode("//setting").SelectSingleNode("//value");

        return xNode.InnerText;      
    }
    catch (Exception)
    {
        return "";
    }
}
 

Jian Kang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Jian
7/21/2008 12:35:18 PM
Reply:

Similar Artilces:

I am trying to find .NET FrameWork class libraries and ADO.NET libraries maps to hang in my cube at work or at home.
Hello,    I am in search of the .NET Framework 1.x and 2.0 and 3.0 class library maps and ADO.NET class library maps to hang/pin to my cube at work and also at home. I believe that helps understand more about the Framework and also if some thing is presented in a pictorial representation I guess I can learn more than reading whole lot of stuff.   So is there a place on the net or any company that offers this to buy or down load?   Any inputs or help me finding on this is greately appreciated.   Thanks in advance, -L   The Visual Studio magazine use...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Linq to Objects
I have a web project with a seperate class library and I am trying to use Linq to Objects within that Class Library:Private people As New List(Of Person) Public Sub doSomething()       Dim somepeople = From p In Me.people _                                   Order By pEnd SubBut evem writng the above I get an error of:"Expression of type 'System.Collection.Generic.List(Of Person)' ...

We Need ADO Wrapper Class Methods using Ado.net
We Need clue / suggesion for writing the ADO Wrapper Class Methods below using Ado.netAny one example for any method will help1) getBookmark()2) setBookmark(currentBM)3) Delete ()4) close ()5) getStatus()6) getDataSource()7) DataMember()8) Update(Fields,Values)9) ActiveConnection()Thanks in Advance. You don't say what language you are using (VB or C#), but all you have to do is to create a Function or method and put your ADO.NET code in it.For example, Delete() will obviously have to take a parameter, such as an integer, or array of integers, and the code within it will loop through t...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Insert datetime, using ADO.net VB.net
Hello there,I got a little code there are inserting a record into my msSQL database..But i cant insert the datetime, for one reason?The problem is in line 7 () where i want to insert DateTime.Now 1 Protected Sub SendPmTilAfviste(ByVal modtager As String, ByVal festID As String) 2 ' Connection 3 Dim conn As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True") 4 conn.Open() 5 6 ' SQL-kommandoen 7 Dim cm...

Innovation to ADO.NET
Matisse Software Inc. provides its native ADO.NET Data provider for Matisse 6.0, the Database for .NET. Matisse Software has pushed the envelope of Microsoft ADO.NET architecture and extended it into a powerful Object Access Services component for .NET. Matisse’s extension of ADO.NET demonstrates that ADO.NET can evolve beyond the Microsoft architecture to benefit .NET developers. Unlike the standard ADO.NET data provider, which returns data in a table format to integrate seamlessly with relational products, Matisse has extended the ADO.NET architecture to return data in an object format....

Does .NET map calls for ADO to ADO.NET?
Hello,We are trying to troubleshoot some DB problems from COM objects that call ADO. I heard that when ADO is loaded inside of a COM object by a .NET app, that .NET intercepts the call and re-maps those calls over to ADO.NET. This seems untrue to me, given the nature of ADO.NET being a totally separate technology.Does anyone know for sure whether this does or does not occur?The problem we are seeing is actually almost identical in symptoms to this:http://support.microsoft.com/default.aspx/kb/230101"FIX: Data Queries Sporadically Return Empty Recordsets" Literally, this is what...

How to call or retrieve fields from sql and display in table without using ADO.net, I'm using a dynamic link library....Is the coding different?
Help me! I'm doing my school project on Software Change Management Tool, CR Tracker. I want to display table in the webform, and the table data is retrieve form the sql server. So how do I call the sql so as to display the data in a table? hy..What does that dll contain ?Does it already contains relevant code to connect to a database ? Have a look hereThanksDinuj Nath The easy way to do this is with the use of a data bound grid. The Grid can be customised to look and feel you like. You will need to add a data adapter to your page and a grid. When you setup the data adapter you will nee...

Aspose.iCalendar 1.0 Released!
Aspose.iCalendar 1.0 Released! Version 1.0.0.0 Released on October 21 2004 ...

using an ADO.NET dataset as a datasource for RS
Hi all, Is it possible to use an ADO.NET dataset (as opposed to a Reporting Services dataset) as a datasource in Reporting Services? Thanks. Mike unless I misunderstood your question, I dont think they are different. what xactly is your question.***********************Dinakar NethiLife is short. Enjoy it.*********************** Yes, they are different. The datasource of a Reporting Services report is called (unfortunately) a "dataset," which is different than a dataset in ADO.NET. My question is as follows: let's say, for example, that I create an ADO.NET dataset in V...

How to use Profile object in class library project?
Hi, Could you tell me how to use Profile object in class library project instead of in asp.net 2.0 website project? I understand that compiler can generate methods to get/set profile according to web.config profile section. But it seems Profile can only be used in website project. For example, when a profile is like below: <profile defaultProvider="MyProfileProvider">   <providers>     <add name="MyProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="myConnecti...

Using COM Objects in a VB.NET Class
I hope this is an OK post for this forum - the only other place I could find for it is the ASP Conversion alpha one - I'm converting some legacy ASP code into a VB.NET Class for use in a web application. Here's the problem line: Set Executor = Server.CreateObject("ASPExec.Execute") Which returns this error when compiled: error BC30807: 'Let' and 'Set' assignment statements are no longer supported. If I take off the "set" from the line above, and recompile, i get this error: BC30451: Name 'Server' is not declared. How do you call a legacy COM...

Web resources about - class library project using ado.net - asp.net.object-datasource

Library - Wikipedia, the free encyclopedia
A library is an organized collection of sources of information and similar resources, made accessible to a defined community for reference or ...

Library - Wikipedia, the free encyclopedia
A library is an organized collection of sources of information and similar resources, made accessible to a defined community for reference or ...

Library - Wikipedia, the free encyclopedia
A library's collection can include books , periodicals , newspapers , manuscripts , films , maps , prints , documents , microform , CDs , cassettes ...

Independent review of SLQ lewd photo scandal given to State Library Board for action
A two-month review of how the State Library of Queensland investigated lewd photographs taken of staff members' cleavage by a former senior executive ...

State Library of Queensland lewd photo victims may see images
... see photos three years after they were taken. Three years after a former boss secretly photographed their cleavages, hundreds of State Library ...

Should the Washington Post’s Ties to Reagan Library Be Disclosed in Columns Attacking Bill O’Reilly?
... of interest career.” In his column “Bill O’Reilly Makes a Mess of History,” Will does hint at tension between O’Reilly and the Reagan Library: ...


Amazon’s ComiXology now lets you read comics from your Kindle library
... signature cinematic Guided View experience. Note that after merging, only the comics, graphics novels, and manga in your Kindle library will ...

"Librarians in Japan upset after newspaper published names of books that novelist Haruki Murakami checked ...
... , where somebody says: This reminds me so much of that scene in Se7en where Morgan Freeman and Brad Pitt gain access to John Doe's library check-out ...

Boston library recovers stolen map created in 1612
Historic map recovered 10 years after being taken by antique dealer convicted in theft of over 100 maps

Resources last updated: 12/6/2015 9:04:13 AM