VS2008, .NetFramework 3.5 SP1:
I have built a LINQ data access layer project. When the LINQ data context
was built over an existing SQL2005 database, the connection string for that
database was correctly, automatically, placed into the Settings for the LINQ
project. It works, but it's a "static" connection string.
I would like to be able to use this one LINQ data access layer against both
test and production databases without having to manually change and
recompile the project's connection string each time. Since this is a data
access layer project, the functions within it are called by the User
application project. The User application project has the test or
production connection string within it's settings.
Is there a way to pass the User connection string to the LINQ data access
layer? I would even consider passing the connection string on each function
call to the LINQ project, but my first attempt was unsuccessful, because the
LINQ connection string is ReadOnly.
Public Shared Function GetModuleRowsAc tiveBoot(ByVal strConnectionSt ring
As String) As DataTable
Dim dt As New DataTable
Try
Dim dc As New dcSecurityDataC ontext
Global.Security Linq.My.MySetti ngs.Default.Sec urityConnection String
= strConnectionSt ring
The last statement above is in error because
Global..Securit yConnectionStri ng is ReadOnly.
Anyone tried doing this? 1 6316
On Oct 8, 2:16 pm, "Dean Slindee" <slin...@charte r.netwrote:
VS2008, .NetFramework 3.5 SP1:
I have built a LINQ data access layer project. When the LINQ data context
was built over an existing SQL2005 database, the connection string for that
database was correctly, automatically, placed into the Settings for the LINQ
project. It works, but it's a "static" connection string.
I would like to be able to use this one LINQ data access layer against both
test and production databases without having to manually change and
recompile the project's connection string each time. Since this is a data
access layer project, the functions within it are called by the User
application project. The User application project has the test or
production connection string within it's settings.
Is there a way to pass the User connection string to the LINQ data access
layer? I would even consider passing the connection string on each function
call to the LINQ project, but my first attempt was unsuccessful, because the
LINQ connection string is ReadOnly.
Public Shared Function GetModuleRowsAc tiveBoot(ByVal strConnectionSt ring
As String) As DataTable
Dim dt As New DataTable
Try
Dim dc As New dcSecurityDataC ontext
Global.Security Linq.My.MySetti ngs.Default.Sec urityConnection String
= strConnectionSt ring
The last statement above is in error because
Global..Securit yConnectionStri ng is ReadOnly.
Anyone tried doing this?
That code appears to be incorrect. Doesn't the DataContext derived
class take the connection string in its constructor? In any event,
you can store the connection string in a configuration file of xml
file and read it from there. Since it is just a string, you could
also create one dynamically at runtime or let the user choose one.
There are any number of ways to handle this.
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ronald S. Cook |
last post by:
I've always been taught that stored procedures are better than writing SQL
in client code for a number of reasons:
- runs faster as is compiled and lives on the database server
- is the more proper tier to put it since is a data function
But then I've heard that writing SQL in my client .NET code might run just
as fast? Dynamic SQL or something?
And then there's LINQ on the horizon. Is it a successor to everything
|
by: Marc Gravell |
last post by:
In Linq, you can apparently get a meaningful body from and
expression's .ToString(); random question - does anybody know if linq
also includes a parser? It just seemed it might be a handy way to
write a safe but easy implementation (i.e. no codedom) for an
IBindingListView.Filter (by compiling to a Predicate<T>).
Anybody know if this is possible at all?
Marc
|
by: =?Utf-8?B?U3RlZmFuIFdpbGhlbG0=?= |
last post by:
Hello,
played a little with orcas and went into a problem by building dynamic
queries. I want to build a dynamic where clause but only with parameters that
are not empty =(TextBox.Text != "").
Doing this by building a string is very simple, but how to do it with LINQ?
string sql = "";
if (TextBox1.Text != "")
sql += "Columns_1='"+TextBox1.Text+"'";
if (TextBox2.Text != "")
|
by: BeSharp |
last post by:
I recently stumbled across a pretty interesting LINQ to SQL question and
wonder, whether anybody might have an answer. (I'm doing quite some
increasing LINQ evangelism down here in Germany.).
Assume I want to select rows from a database and check whether a specific
column contains keywords from a list of keywords. The following works just
fine:
List<stringsearchTerms = new List<string>() { "Maria",
"Pedro" };
|
by: Lacutas |
last post by:
Hi
I'm having some problems getting a dynamic LINQ query to work on my DataSet. The idea is that a user selects certain criteria, and then the LINQ query filters through the dataset making the requested changes.
The table I am trying to alter is called RawData, this is defined in a DataSet but has no data columns as these aren't known until some data is imported. As part of my import routine it automatically creates the correct columns...
| |
by: john |
last post by:
I'm trying to build a LINQ expression that will use a dynamic construction
of a LIKE statement in the WHERE clause, it would look something like this
in SQL:
WHERE TaskGroup Like "*00*" OR TaskGroup Like "*20*"
It would be many variations on the above.
|
by: TisMe |
last post by:
Hi All,
I am using Linq to SQL dataclass for my website application.
This was working AOK, but then I deleted and recreated the dataclass
(Seemed the simpliest way of updating the class to reflect DB
structure changes).
Since then, I have to declare the connection differently:
|
by: Plissskin |
last post by:
I need to create an "ad-hoc" filtering page in a web app we are
building. The page would display a number of drop down lists, text
boxes, and radio lists and allow the user to select (enter) some data
that would be used to filter the dataset we return. STANDARD STUFF.
Below is simplified version (not compete) of how we solved this with
ADO using javascript on the client to build a where clause that we
would use on our SQL SELECT...
|
by: giddy |
last post by:
hi,
Yes its a design question again. =)
If I have something like:
class Person
{
//functions:
static Person GetAllPersons();
static Person Search(string field,string value);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |