Architecture :: Creating A DB Connection In My DAL Class File?
Feb 17, 2010Below is my class file.
[Code]....
Below is my class file.
[Code]....
i have the following code:
[Code]....
I was trying to implement as above. How can i call this class from the code behind of my page, and call the methods Open and Close connection ?
How do i instantiate the object ?
weather to create each class libaray project for Interface, Service, Model, DTO, Repository ?
View 1 RepliesI will explain the my current yet simple architecture of my application(s). At the moment I have my main web application as a separate project. I then reference the CoreBLLDAL (Business Logic and Data Access) Project so that several projects can have access to the BLL/DAL Project.
Within the CoreBLLDLL Project I use TableAdapters for my DAL.
I have just upgraded to VS2010 and I would like to make use of the Config Transforms, allowing me to have a separate web.config for test and production - however, TableAdapter get the connection string from the Settings.settings file.
How can I change the TableAdapters to get the connection string from the app/web.config file? I read that you can change this within the designer file for the TableAdapters by using ConfigurationManager, however, I tried this but I do not have access to the ConfigurationManager namespace. I presume this is because the project is a class library and not a web application - I am not too sure.
I am having problem when i was trying to attach .mdf file while create a new connection of SQL server, create a new connection of SQL database file and open the database in Server Explorer. I am using VS 2010 Ultimate and SQL Express 2008 R2.
Here are the error message.
1. Attach .mdf in SQL database file and open the database in Server Explorer
2. Create a new SQL server and attach .mdf
how to create a class library file and how to implement in web forms?
View 3 RepliesI am preparing for an Access2007 db conversion at the beginning of the year and would like to know what the best process would be for connecting to the sqlserver2005 database. I have read about adding the connection string to the web.config file. I have also read about using ADO.NET and put the connection information into a class and not the web.config file.
I would like to hear from others as to what you have used, are using, or plan on using for a webapp (vs2010), and why so I can get an understanding.
just for my testing purpose i know i can define both the connection's outside in a single web config file by different name's and access them in my front end according to it but what if i want to have seprate for both connection's web.config situation is like this see image so i want to access my connections from second web config file how i can do that.
[Code]...
i tired this but its giving error
[Code]....
Is it possible to connect to a Remote Desktop from my ASP.net (I easily done it in .net windows application with a 4 line code and"Windows Terminal Service Control")application, If so can you guide me through it. Many thanks in advance.NB:I want to achieve it without using ActiveX control that work in IE, because with that every client would have to use IE and install the control.
View 6 RepliesI'm currently looking into a project where specific users can create web forms on the fly and save them as templates whcih are data bound.I know InfoPath has this ability; but you need SharePoint unfortunately we do not have this. I have looked into XForms, but found nothing helpful within the .net arena.Has anyone done something similar or know of a product within the .net arena which could be used.
View 1 RepliesHow to find connection string path in three tier architecture?
View 3 RepliesI am currently working on the connection between ASP.NET and Oracle. I tried to search over the net and know there are many ways. Is there any 'normal practice' on which method to be used? Or it depends?
I want to start creating sites with simple backends! I don't know much about databases though and I don't want to jump straight into creating sites with databases anyway. So I want to find out what the best way of creating a simple backend without using a database is.
I have an asp.net webpage which is a prices page detailing the prices of services at a hair salon. The prices change every 6 months so I want to give the client a simple backend so he can update the prices himself. The backend will just be a table of inputs populated with the current prices which can be changed and then click 'save changes' to update the site.
Now what is the best way of implementing this?
A) In the prices page, hard code an html table, within each cell code a <span> tag with an id for the price that will go within the span tag like id="menscut" and within the span tag hard code the price of the service. Then wirte a C# class called 'edit' that is used when the 'save changes' button is clicked on the backend page. When 'save changes' is clicked the 'edit' class parses the prices.aspx page and finds <span id="menscut">£20</span> and then changes it to <span id="menscut">£22</span> (or what ever new price has been entered in the backend) and then saves the new edited prices.aspx page over the old one on the server.
or
B) Don't hard code prices into the prices.aspx but instead store the prices in a seperate .txt or .xml file. Every time the prices.aspx page loads it runs a class called 'populate' which extracts the prices from the .txt file or .xml file and inserts them into the table in the prices.aspx page. And now the edit class instead of editing the prices.aspx page it edits the .txt or .xml file.
So which of those ways is better, or if they are fairly even pegged what are the pros and cons of each?
Or are there any other options I haven't thought of?
I have an ASP.NET project which is pretty n-tier, by namespace, but I need to separate into three projects: Data Layer, Middle Tier and Front End.I am doing this because...
A) It seems the right thing to do, and
B) I am having all sorts of problems running unit tests for ASP.NET hosted assemblies.
Anyway, my question is, where do you keep your config info?Right now, for example, my middle tier classes (which uses Linq to SQL) automatically pull their connection string information from the web.config when instantiating a new data context.If my data layer is in another project can/should it be using the web.config for configuration info?If so, how will a unit test, (typically in a separate assembly) provide soch configuration info?
I am in the process of creating an audit trail system. Simple enough. Certain fields require audit trail. What is the best design concept to allow this to work in multiple applications without having to change much? I would of course leave it to the admin of the site to add what fields should be audited, but the logic is the problem. Would implementing the interface IComparable be a place to start? My initial thinking is to compare 2 arrays against eachother and do an insert of what fields are in question. Array1 are the fields in the form, array2 are the fields from the sql table that require auditing.
View 8 RepliesI've created 2 multi dimensional arrays (2 dimensions each), I want to feed them both into a function, and I would like the function to spit out an array or list containing both of them as arrays, so I can use them as they were before they went into the function.
The way I've done it at the moment is probably very inifficient and I'm having trouble accessing it properly.
What follows is my attempt to put the 2 arrays (attackerarmy and defenderarmy) into a new array called armyresults and adding an additional dimension to tell me if the record belongs to the attacker or defender:
[Code]....
Since I've already got the 2 arrays I want in the function, I've rather not inefficiently force them into a new array, only to try to re build them again when they come out of the function.
how to out 2 arrays of unknown size into an array of arrays for the return statement of my function, and then how I can access those individual arrays so I can easily copy them back out into their original form?
I am currently using datasets for my data access layer. I currently store the connection string in the web.config file. I need the ability to change the connection to another database before any queries are processed. Is there an event that is triggered or a base class that can be modified that intercepts the process of retrieving the connection string from the web.config file? Is there any way to handle multiple database connections using the same code base and also take advantage of the connection pooling? I understand the best method is to get rid of datasets and use custom data objects.
View 2 Repliescurrently i have db name , server name & coonection credentials for sql daTAbase hardcoded in webconfig but i need to create a dynamic connection string in which db name will change currenly i have a main .aspx with a button & on its click event i get the connection string frm webconfig and move on to next page
wht i need is in the main page i need to populate all the db of a particullar server in a dropdown the user will first select the db frm drpdown & click the button & with the db name frm dropdown connection string shld be formed
So I started working on my first asp.net application that involves logging in and databases, and soon after i started messing around with a static class. I "discovered" that if you make a variable static, all sessions share that variable (I for some reason was originally assuming that each session had its own copy of that "static" class). Anyway, after discovering this I thought to myself "how could this possibly be useful to me" and thought that itmight be a good idea to make a single static database connection for all of the sessions, rather than storing that as a session variable for each session. Does anybody know what would be the pros and cons of this approach?
View 5 RepliesI have a block of SQL statements that I like to use as a sort of function.
I was thinking that I could make a class and inherit all of the master function, then add the parts that I need for other sections of the program in a sub class.
The problem is, up to this point I've been programming ASP .Net through visual studio, and it's kind of just programming behind controls. I'm not sure where to put the class/function/method/interface, or whatever we call it.
Of course you probably know that visual studio creates a bunch of partial classes when you do an ASP. Net application... so.. to get access to a function like object, across classes.. use an Interface?
Task is to develop class libraries that can be re-use in projects but assambies should be copy righted. By this I mean developer will not give the code of class libraries to the clients yet they will provide the code of there sites/ applications, these libraries will be used just as internal development libraries. I want to make Business Logic Layer, DAL, Business Objects as class libraries
Q1. How I can control unathorised use of libraries ?
Q2. How to make assamlies non extendable ?
Q3. What security measurs I should take on this.
In a project im working on there are many sql tables containing different ID, Name pairs. Those are represented as Enums in classes that need them however that requires casting since tables contain ID only.Also when serialize the Enum contains the ID not value.
View 3 Replieswhat is the function of abstract class, why design pattern need to build BLL and DAL
anyone give an example for my reference as I am getting strat to build my web-based project
I am trying to create a comments page for users to review and comment on an article. I have 2 buttons on each comments posted by users; "Like" and "Don't Like". I am stuck with how to track which user voted already for a given comment. I am thinking of two options and would like to know if they are they way to go or is there a better solution.
Option 1: I have created a table in my database with stores, the comment id, the userid of the user who rated it and the value "like" or "don't like". So each time I have to query my table to find out if this user indeed vote for a given comment. The table unfortunately grows exponentially!!
Option 2: I store the commentid, userid, and "like" or "don't like" value in a cookie on the client's machine. I read the cookie and find out if the user has already voted on a comment. This is proving to be VERY quirky with cookie expiration, growing cookie size and also multiple users on the same machine.
In either way, my test case of ~1500 users, and 2 Million comments, this is getting to be HEAVY on both methods. Is there anything better?
When I open an ASP.NET 3.5 project using VWD2010, I get a prompt error message,"The connection property in the web.config file is missing or incorrect.The connection string from the .dbml file has been used in its place."however, my project works successfully.
View 1 Replies