.net - Handle Lazy Loading/ConnectionString In Library?
May 4, 2011
I've created a solution that contains a single class library project and two web applications. My main problems are the connection strings. These are held/declared in the web projects and I'm having to pass them into the class library every time I perform any kind of data access. I sort of understand why I should do this so I'm going with it for the moment.This has now led me to a problem/question with lazy loading. I'm using lazy loading for the following property:
Public Property KeyRelationshipManager() As Employee
Get
If _keyRelationshipManager Is Nothing Then
_keyRelationshipManager = Employee.GetEmployee(_keyRelationshipManagerStaffNumber)
[code].....
I need to pass in the connection string to that function.This means I would need to pass the connection string in to the property every time I use it so I could pass it into the function.Is this correct? It doesn't 'feel' right to me because I'm going to have to adjust a huge number of functions and property and pass through the connections string.
View 1 Replies
ADVERTISEMENT
Mar 6, 2009
i have a sql query that can bring back a large number of rows via a DataReader. Just now I query the DB transform the result set into a List(of ) and data bind the Grid to the List.This can result occasionally in a timeout due to the size of Dataset. I currently have a three teir setup where by the UI is acting on the List of objects in the business layer.
View 3 Replies
Sep 19, 2011
I just recently learned about the uses of static local variables in VB.NET and wondered about it's potential use in lazy loading properties.
Consider the following example code.
Public Class Foo
Implements IFoo
End Class
[Code].....
As far as i can see, this has a few advantages over the usual implementation, primary your inability to access the variable outside of the property, as well as not having to use an additional variable.
My question to you is: Which of those is the "right" way to do it? I know that static variables have additional overhead, but is it bad enough to create, in my personal opinion, unclearer code that can be misused easier? How much performance do you lose compared to the "traditional" method? How does it matter for small classes compared to huge factories?
View 2 Replies
Apr 27, 2011
I'm merging two of my projects that can share a lot of the same classes into one solution with two web applications and a shared class library.
I've literally just dumped all the classes into the class library project and as expected I've got a ton of errors to fix. My main problem at the moment is the connection string. Currently I have this (which is obviously not going to work):
''' <summary>
''' Initialise the data access layer by loading the database connection string from the Web.Config file
[Code].....
View 1 Replies
Oct 6, 2010
I've decided to build wizard style library to handle many wizards and make it more simple to work with. The difficulty is that next step window changes depending on user selection on current form with a lot of controls in each of them. After long time thinking I think best would be to recreate similar to TabControl and TabPage controls and instead tabs would be a in-built command Next, Previous and Finish buttons as default in TabPage control. I've tried something to create similar but with no success yet.
[Code]...
View 7 Replies
Jul 22, 2010
i'm working on a project right now and I need to create a graphic library.The game I'm experimenting with is an RPG; this project is expected to contain many big graphic files to use and I would prefer not to load everything into memory at once, like I've done before with other smaller projects.So, does anyone have experience with libraries such as this one? Here's what I've came up with:
Have graphic library files and paths in an XML file Each entry in the XML file would be designated "PERMANENT" or "TEMPORARY", with perm. being that once loaded it stays in memory and won't be cleared (like menu-graphics)The library that the XML file loads into would have a CLEAR command, that clears out all non-PERMANENT graphics I have experience throwing everything into memory at startup, and with running the program running with the assumption that all necessary graphics are currently in memory.
View 1 Replies
Jan 4, 2010
I have a strange problem with a lazy load property in my class.[code]The problem i have is that when i create a new instance of the class the value of 'mMarksLoaded' is true however when i put a break point on this section of code, execution is never interrupted.Is it possible that the .net framework is accessing this property behind the scenes?
View 12 Replies
Dec 1, 2009
The code below will throw an InvalidOperationException: The ConnectionString property has not been initialized. The exception is thrown at the line calling Connection.Open() in the Load method. If I use the try-finally statement instead of the using statement, everything works correctly. Can anyone explain why the exception occurs with the using statement?
[Code]...
View 2 Replies
Jun 21, 2011
I have a Visual Basic Class Library project. It generates a DLL. Is there a method to generate a static .LIB to which I can do a static link?Alternatively, can I do a static link against a DLL?
View 6 Replies
Oct 21, 2009
I use dbf files from db2k in my application.When I try to connect, it takes a long time and I find the application exited without any error msg.The connection string I use:Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\agbvseng01APPLISNomenclature_Eng_Bvs;Extended Properties=dBASE IV" Data source is on a server.I dont know why this happens.
View 10 Replies
Jan 21, 2012
Dim SQLInfo As String = "server=https://lotus.x10hosting.com:2083/frontend/x3/index.html;" _
& "uid=uid;" _
& "pwd=pwd;" _
[code].....
View 7 Replies
Jan 6, 2011
I designed a DAL (data access layer). This DAL mainly consists of a handfull of methods to call stored procedures. All methods are shared. So no instance generation of the DAL class occurs.
The DAL with it's single class is located in an own project. The connection string is defined in the app-config file of this project.
I want other applications to use the DAL class by referencing the dll generated by the DAL-project. For this reason, I can not any longer define the connection string in the DAL app-config as it is, because the client application determines which database needs to be used.
- Dropping the "shared" keyword of my methods. Create an instance of the DAL class. Add a property for the connection string. When application starts, create one global or multiple local instance/s of the DAL and set it's connection string property.
Comment: I don't like this, because it implies more coding work on the application code side (create instance of class, assign connection string)
- Granting the DAC class access to the connection string defined in the application code by adding a connection string property inside the application code. Thus the DAC class remains "shared".
Comment: I'd need to set a reference from the DAL to the application code during without knowing the application yet. I could try stack tracing or something like that. But it feels to convoluted for me.
View 6 Replies
May 22, 2012
I am just having a hard time figuring out what does the number 2 in
ConfigurationManager.ConnectionStrings(2).ConnectionString
define? What does it mean?
View 1 Replies
Jul 15, 2009
I've looked at a lot of posts on different forums where others have received the same error. Most say they were not referencing the connectionstring from the web.config file correctly, or they were trying to open the connection before setting the connectionstring. Well, if that were the case for me, then how does it work on two different systems, but not on the third? It works on my development PC and on the development server, but not in the production environment. The difference is the web and DB server are separate physical servers in my production environment and on a single server for development. My setup, error message and code will be listed below.
I can simulate the error on my PC if I rename the connection string in either section of the web.config file (appsettings, connectionstrings) to something else. You will see how I have tested both below.
[Code]...
View 2 Replies
Jun 29, 2009
I know below code causes an error since "Property 'AAConnectionString ' is 'ReadOnly". What other choice do I have to assign a value for a user ID or a password with a value of textbox by coding?
My.Settings.AAConnectionString = "Data Source=bb.allgood.com;Initial Catalog=aadb; Persist Security Info=True;User ID=aa123;Password=aa123"
View 7 Replies
Apr 27, 2012
I create project in my pc with vb.net and sql database when i tried to run this project to another pc there is error occurred that the connectionstring has not been initialized. I really troubled this from last one week to solve the problem. how to change the connectionstring on client pc at runtime or any other way to create a connectionstring that has auto detect in any pc where the program is installed.
View 5 Replies
Feb 18, 2010
Im writing a app using vb.net, which has multiple front ends e.g a windows service and a windows forms app. Ive got all my business logic and database stuff compiled into 1 project (producing a dll) then the different front ends as different projects calling the dll.
In the backend / dll project Im connecting to 2 databases using app.config to store the connection strings and DataSets / TableAdapters. This all works fine .... Until
When I deploy the windows app, it deploys the exe and the dll produced by the backend project. when its installed on a client PC, Im need to point the app at a different db server and therefore need to change the connectionstring, but its packaged up in the dll.
is there any way I can use a settings file within my windows app (therefore deployed with my windows app) where I can define the connectionstring, which onload gets passsed through into my dll, so the backend connects the correct database. I know how to pass standard settings through (strings etc) but the my.settings.connectionstrings seem to be readonly.
View 2 Replies
Aug 31, 2009
Im trying to make a query inb a dataset (to fill a report) Why it dont let me do a select (that will return rows)?
View 2 Replies
Jul 29, 2009
How does a real life connectionString look like? I my sample application, I have this in the app.config file:
[Code]...
View 9 Replies
Jan 16, 2010
ConnectionString on real website
View 1 Replies
May 11, 2012
I have a web application that works perfectly on my local machine but not once Ive uploaded to the hosting server I get:
Server Error in '/' Application.
The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized......
View 4 Replies
May 11, 2012
I have a web application that works perfectly on my local machine but not once Ive uploaded to the hosting server i get:Server Error in '/' Application.The ConnectionString property has not been initialized.Description: An unhandled exception occurred during the execution of the current web request.review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.Source Error:Line 423:Dim conn As New SqlConnection(connstring)
[Code]...
View 2 Replies
Apr 23, 2010
When I add a datasource via the wizard the connection string is either writen directly in the dataset.designer or there is a reference to the projects settings. Either way I am figuring out if I could change it dynamicaly when my app starts up ?
[Code]...
View 5 Replies
May 22, 2009
I have created a program using VB2008 it has two forms that I am having a problem with FORM2 has a textbox and a button that I use to pass a string to the code in FORM3 that is used to populate DATAGRIDVIEW1. I am using MS ACCESS 2007 for my database. I have supplied the code I am having trouble with below. When I run the program and type a string into the textbox and press the button I get this error: oledbException was unhandled: No value given for one or more required parameters. The area that was highlighted was m_daDataAdapter.Fill(ds). How can I get this code to populate the
[Code]...
View 2 Replies
Nov 15, 2009
I have this now:
Code:
<connectionStrings>
<add name="DataProject.My.MySettings.CobrosConnectionString"
connectionString="Data Source=***.**.***.**;Initial Catalog=test;User Id=test2;Password=pass123;"
providerName="System.Data.SqlClient" />
[Code]...
How do I set/get the connection string encrypted instead of plain text?
View 2 Replies
Apr 22, 2011
i have visual studio 2008 in with i'm doing an ASP.NET application.Now i want to link my pages to SQL Server 2008. On my page default.aspx, I put a gridview and then i can find the connection string from there to the sql server db, which i can then put in a class and have all pages use it.Is this the only way to find the connection string for any servers on the network or are there other ways (probably better ways of finding the conn string?)
View 1 Replies
Jul 11, 2009
I keep getting an error that the ConnectionString is not initialized.
Here is my
'* Configure data adaptor and fill data set
sqlDABC.SelectCommand = sqlCmd
sqlDABC.Fill(dsBC, "Supplier")
View 3 Replies
Jun 1, 2009
I am having an issue using a datagrid. I can use it fine on my development machine in VB 2005. But, when I deploy it to a client and they try to access the datagrid this message comes up:To run this example, replace the value of the connectionString variable with a connection string that is valid for your system.
Both machines are running Windows XP Pro (SP3). Is there some type of assembly for datagrids that I am missing in my application or some prerequisite that I need to install as part of the solution.
View 11 Replies
May 21, 2009
I would like to save my connectionstring in my.settings but this property is only readonly.When i would save it as a String, then I can't find it with the wizard for building a report. [code] is there also another way to build a connectionstring? this works, but the type of My.Settings. Data base String is a string and not a ConnectionString.
View 1 Replies
Jan 15, 2012
i get error " the connection string property has not been initialized" while inserting. am using MS access as database.
View 4 Replies