DataSource Controls :: One Linq Query With Two Db Connection?

May 31, 2010

I want to use from two db connection in one linq query

My sample is:

int a=1;
if(a==1)
DataClasses1DataContext1 db = new DataClasses1DataContext1();
else
DataClasses1DataContext2 db = new DataClasses1DataContext2();
var q =
from c
in db.F_Groups
select c;

In this code a=1 so db connection is DataClasses1DataContext1

I want if a=2 then db connection = DataClasses1DataContext2

but this code is error.

db connections is completely same but in two deferent class a db connection is sql and another is oracle

View 4 Replies


Similar Messages:

DataSource Controls :: How To Convert Sql Query Into Linq Query

Mar 10, 2010

select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid

View 5 Replies

DataSource Controls :: Common Connection String In LINq To SQL Files?

Feb 20, 2010

I am using LINQ to SQL files in my class libray since every LINQ to SQL sources file is a seprate file and i have to set database connection string in each class library. Now, i have total 7 class libraires in my project how connection string be passed from web.onfg to LINQ file, so that i don't need to manually change the connection string. lke we did in asp.net 2.0 using connection string property in class file library.

How could we pass the same in LINQ's designer file.

View 4 Replies

DataSource Controls :: Internet Connection Loss While Executing Query?

Jun 23, 2010

I am having problem in diffrentitate error between internet connection loss error and Other Error in query for example: duplicate record found.

Both the error fall into System.Data.SqlClient.SqlException category.

But the way to handle both this 2 error is different.For connection error , i need to bring user to connection loss page while for duplicate record found error, i need to show the user a pop up.

Unless i do a checking exactly on the error message , else i have no ways to differentiate connection loss error and any other error. Am i correct for this?

View 1 Replies

DataSource Controls :: How To Convert, The Code To Query A SQL Database Using A DSN-less Connection

Sep 10, 2010

How do we convert, the following code to query a SQL database with ASP using a DSN-less connection

[Code]....

View 2 Replies

DataSource Controls :: Query Using Linq To Sql?

Jun 25, 2010

I´m using Linq to Sql in my asp.net application, but the problem is:I have a query like this:

[Code]....

My query is not returning anything, how do I do to get this?my problem is with this interval I need to have.

View 2 Replies

DataSource Controls :: LINQ - Timeout Period Expired, Connection Pool?

May 19, 2010

I'm getting the following error after uploading my site on live server:Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.i'm using the following code:

public static IQueryable<Property> Properties(string name, string city, string state, int pageIndex, int pageSize, ref int total)
{
ServerDataContext server = new ServerDataContext();
total = server.Properties.Count(x => x.Name.StartsWith(name) && x.City.StartsWith(city) && x.State.Contains(state));
return server.Properties.Where(x => x.Name.StartsWith(name) && x.City.StartsWith(city) && x.State.Contains(state)).Skip(pageIndex * pageSize - pageSize).Take(pageSize);
}

View 1 Replies

DataSource Controls :: How To Convert Sql Query To LINQ

Feb 13, 2010

How can I convert this sql query to LINQ ?

[code]...

View 1 Replies

DataSource Controls :: Linq To Sql Query / Zip Codes?

Feb 18, 2010

Im doing thing profile, zip code thing on my site. One table has a list of zipcodes and in the other is a profile and there they keep what zip code they entered. I already have the radius code but idk how to get a list of all the profiles in a radius.I'm going to store the zip codes that come back from the zip code table in a arraylist and put it in a session state so i don't have to keep getting the same thing over and over again. The problem is i don't know how to write the linq to sql query to take the arraylist of zip codes and look up all the users that have that as there set zip code in there profile.

View 1 Replies

DataSource Controls :: Return First Value From A Linq Query?

Mar 12, 2010

Is there a way opf getting the first value from a linq query so for example

[Code]....

View 2 Replies

DataSource Controls :: Add A New Item To A LINQ Query?

May 13, 2010

So I'm trying to add a single item to a query I wrote. The query is then pass to the e.Result of a LinqDataSource_Selecting event. This datasource is being used by a dropdown list and label in a listview.

I am trying to add a "New" field to the end of the list.

Currently I have this working, but it seems like a really messy solution. First I make a class with the fields I need:

[Code]....

Then I build the query:

[Code]....

Then a second list and query with the new value:

[Code]....

Finally, I union the two and set the e.Result:

[Code]....

View 5 Replies

DataSource Controls :: Retrieve Value From LINQ Query?

Mar 20, 2010

I need to know how to extract the result of the attempted LINQ query below and set it equal to the strFile variable.Everything Intellisensed OK here but ine 5 shows a syntax error at the parenthesis.

[Code]....

View 12 Replies

DataSource Controls :: Linq Query With OrElse?

Apr 7, 2010

I'm having a problem with a Linq query where is executing the second half of an OrElse even though the first half evaluates to true.

[Code]....

When Manufacturer is null, I get a NullReferenceException. The "Manufacturer.Trim()" should never be executed, because the first half of the OrElse evaluates to true. Just to test it out, I also tried this:

[Code]....

This actually works fine... Manufacturer.Trim() is never executed, and I get no error. Why is the Trim() statement being executed in the first case? If Manufacturer is null, then it shouldn't be.

View 4 Replies

DataSource Controls :: Random Results From A LINQ To SQL Query?

Jan 23, 2010

I have this LINQ query:

var agnts = (from a in db.agents select new { a.userid, a.name }).Take(10);

How can I get randomly get 10 records from my agents table?

I have tried:

agnts = agnts.OrderBy(n => Guid.NewGuid());

but this doesn't seem to do anything.

View 5 Replies

DataSource Controls :: SQL Query Re-Write In Linq To Entity?

Jan 26, 2010

Need to figure out the correct way to do a simple SUM function in Linq, but also manipulate one of the feilds coming back by doing a Substring on it, here is the original SQL query:

[Code]....

View 1 Replies

DataSource Controls :: LINQ And C# - Accessing More Then 2 Tables In A Query

Apr 23, 2010

As the title sugests, I am missing a (basic?) concept as I teach myself asp.net, linq, and C#. It has been awhile since I've done anything object oriented, so I don't know how much that is impacting this gap in my understanding. Anyhow, here is what I am trying to do. I have three SQL Server tables: PERSON, POSITION, AREA. There is a 1 to many relationship between PERSON and POSITION, and a 1 to 1 relationship between POSITION and AREA. Given the following code I verify who the person is who has logged into the browser:

[Code]....

I want to be able to return all of the AREAs the person is able to access, based on the position they currently hold. I am able to easily do this in a SQL Server query, and I am sure I can do this with a SQL stored procedure once I pass the EMPLOYEE_ID to the procedure. However, I would rather do this in the page_load event, and load the returned results into gridview1 for the viewer. The issue I am running into is in building the LINQ query. When I try to build it, I can only get access to two of the three tables, depending on which table I select with db. Is it possible to access all three tables in the same query?

View 10 Replies

DataSource Controls :: Finding A Field In A Linq Query

Mar 1, 2010

I have a field name as a string and i want to find it in a linq query. so something like this

[Code]....

View 3 Replies

DataSource Controls :: Linq To Sql Query / Could Not Translate Expression?

Mar 26, 2010

I have the following LINQ query which works correctly:

[Code]....

The following query, however causes an error:

[Code]....

"Could not translate expression 'Table(t_f2f_event).Where(e => ((e.EVT_START_DATE > Invoke(value(System.Func`1[System.Nullable`1[System.DateTime]]))) && (e.EVT_START_DATE < Invoke(value(System.Func`1[System.Nullable`1[System.DateTime]])))))' into SQL
and could not treat it as a local expression."

View 2 Replies

DataSource Controls :: Calling Function In Linq Query

Apr 8, 2010

I have a problem here.In my database I store member status in 1 and 0, when it come to my gridview I need change 1 and 0 to active and inactive. My company is using Linq, so I must follow. I wrote in this style, I calling a changeToWord() function to change 1 and 0 to active and inactive.

var q=from a in db.members
select new{
mem_name=a.name,
status=ChangeToWords(a.status)
}

It compiles with no error, but when I execute the page, it prompt out a error message to me.

View 3 Replies

DataSource Controls :: Can Get Two Tables In Only One Query With LINQ To Entities

May 20, 2010

can get two tables in only one query with LINQ to Entities

Code for example:

[Code]....

View 4 Replies

DataSource Controls :: View The LINQ To DataSet Query?

Feb 23, 2010

I'm trying to find an easy way to view the query that has been generated as part of the LINQ to DataSet syntax in my application. I found Scott Gu's blog and his creation of the Linq to SQL Debug Visualizer but it doesn't appear to work for my application. I am using OracleClient if that is important.

My next step is to simply configure the Oracle Manager for the database to see the query but I can't believe there's not an easy way to view this generated query.

View 3 Replies

DataSource Controls :: Using IF Statements In LINQ Insert Query?

Jun 7, 2010

I tried to find a LINQ section on this forum, but couldn't, so I'll post this here since is deals with LINQ, C#, MVC, SQL Server, and well...just about everything.

Here's the details....My Application is an ASP .Net MVC 1.0 app, using C# 3.5, SQL Server 2005 Std, and LINQ to Entity.

In my View, I have numerous Html.CheckBox controls, they get passed to my Controller as a string collection via a JQuery Ajax call. The values of each checkbox are seperated by a comma(,). I then Split the string, to get the individual values. The overall purpose to to allow users to build a custom report with only the data elements they have checked the boxes for. Here is my controller:

[Code]....

The part that I am having a problem with is that I only want to Insert the data elements into my DB table for the ones that the user has selected the checkbox for. So, for example, I'd like to do something like this:

[Code]....

I don't know if there is a LINQ switch statement in which I can access outside variables and the columns of the table, or any thing like that.

View 1 Replies

DataSource Controls :: Much Slower Linq Query Than Optimised Sql ?

Feb 19, 2010

Slow query.Much slower linq query than optimised sql ?

View 1 Replies

DataSource Controls :: Check Query Return Value Or Not In LINQ

Jun 2, 2010

i have a Linq query that check something in database

after that i want to check if record find in database or not

dim re = From r in db.mytable _
where r.ID = _ID
Select r

how can i check the re return somthing or empty

View 1 Replies

DataSource Controls :: Cannot Get The Linq To SQl Query Return Type Working(C#)?

Apr 14, 2010

I am trying to fill a gridview with the data from Product table selecting few columns . I am using 3 - tier architecture and in DAL getproduct(userid) I am writing the query but cannot figure out exactly how to get that working .. here is piece of method I wrote

public List<Project> GetProjectList(int ownerId)

View 11 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved