VS 2010 Join Tables From 2 Different DB's?
Nov 30, 2011Is it possible to join a table from a SQL Server DB and an oracle DB?
View 1 RepliesIs it possible to join a table from a SQL Server DB and an oracle DB?
View 1 RepliesIwant to join two tables,'Employee' and 'Dispatch'. Dispatch has column 'DispatcherID' and 'TechnicianID' which are both foregn keys to EmployeeID in Employee table.I want to join these two tables using EmployeeID so that i can obtain the matching name to each id.but it only works when i make a single join to either DispatcherID or TechnicianID and not for both.
[code]
select Employee.firstname+' '+Employee,secondname as Technician,Employee.firstname+' '+Employee.secondname as Dispatcher from Dispatch inner join Employee on Dispatch.TechnicianID=Employee.EmployeeID inner join Employee on
[CODE]...
In my datagridview I was fill in using join tables (table1 = pr_employees, table2 = pr_employee_deduction). My problem now is during save button I want to update records from table2 only.[code]
View 3 RepliesI've been using Java for a number of years, and now I'm at the beginning again with VB.NET.How would I go about joining two tables?- order doesn't matter, as long as i can print/display the order
Here's an example of what I'd like to do:
table 1
data 1 , data 2 , date time
12 , 23 , 2010/8/20 10:00:00
[code].....
I'm trying to do a join on two tables but i'm having a hard time. Here's the table schemes:
table1 : tbl_Trainees_IntentToParticipate
Scheme:
TraineeID (PK)
FName
LName
I want to select all TraineeID/FName/LNames from table1 where TakenTest (from table2)= false
heres the sql statement I have so far:
SqlJoinStatement = "SELECT tbl_Trainees_IntentToParticipate.FName, tbl_Trainees_IntentToParticipate.LName" _
& "FROM(tbl_Trainees_IntentToParticipate, tbl_Trainees_TabScores) " _
[code]....
how to join 3 tables, I have the following statement but I'm getting a missing a (syntax error "operator error")
da = New OleDbDataAdapter("SELECT [S].[Scheduled Vege], [V].[Description],
[DS].[Task], [DS].[Task Date], [DS].[Completed] FROM [Scheduled] AS S
INNER JOIN [Date Schedules] AS DS ON [S].[SchedID] = [DS].[SchedID]
[code]....
I am working on a Visual Basic 2008 program using an Access 2000 database. My SQL codereturns no records, but I know the table has a record. A simplified example of the code looks like this:
SELECT Table1.Field1, Table1.Field2, Table1.Field3, Table1.Field4, Table2. Field1, Table2.Field2 FROM Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field1 AND Table1.Field2 = Table2.Field2 WHERE Table1.Field1=@Field1 AND Table1.Field2=@Field2;
[code].....
here what i try to get:
Table A:
Field: Name A
Field: Id_A
[Code]....
In fact i want to list in grid the table A with a column which contains a checkbox and is checked if the item is include in table B (field TableA_Id_A).
I am tying to build a COMMAND that joins two tables from two different access databases in vb.net,
View 4 RepliesLet's say I have Plans and Documents
Dim myPlans = _context.Plans.Where(predicate1)
Dim myDocuments = _context.Documents.Where(predicate2)
I have structured the where clause for each using PredicateBuilder. So, myPlans and myDocuments have a correct SQL statement. What I'd like to do is join these two tables into one linq statement. The problem I'm having is that, by default the AND condition is joining the where clauses.
myPlans Where clause : (p.name like "%test%" AND p.name like "%bed%") OR (p.description like "%test%" AND p.description like "%bed%")
myDocuments Where clause : (d.name like "%test%" AND d.name like "%bed%") OR (d.description like "%test%" AND d.description like "%bed%")
When I combine the two the desired result Where clause is:
Where (d.ID = p.ID) AND
(myplans where clause above) OR (mydocument where clause above). Meaning, I'd like the two where clauses in each of the tables to be "or" instead of "And".
The current result where clause is:
Where (d.ID = p.ID) AND
(myplans where clause above) AND (mydocument where clause above). Meaning, I'd like the two where clauses in each of the tables to be "or" instead of "And".
I'm forming the statement like this:
Dim test = From d in myDocuments _
Join p in MyPlans on d.ID Equals p.ID _
Select d.Name, p.Name
I used INNER JOIN to bind the two tables and my problem is how to populate/show on the datagrid.[code]....
View 12 RepliesI have two tables 1) tblRequests and 2.) tblMainTags. The Fields in tblRequests are Tag_Request_No, Employee_ID , Accepted, Accepted_Date, and Accepted_Time. The Fields in tblMaintags are Tag_Request_No, Tag_ID, Completed, ... The fields 'Accepted' and 'Completed' are set to YES/NO.
[Code]...
Here's what I want to do:
Dim queryX = From m In db.Master
Where m.Field = value
Group Join d In db.Detail
On m.Id Equals d.MasterId Into Group
Where d.Field = value
In English, I want to join the master and detail tables, specifying conditions on each. But this causes the following compiler error:
"Name 'd' is either not declared or not in the current scope."
It works if I put this same condition in functional form:
Group Join d In db.Detail.Where(Function(x) x.Field = value)
but I think this is more typing, harder to understand, and introduces that irritating dummy variable. I really would prefer to use the query comprehension syntax. Is there a way to accomplish this?
how to make a report which is from join tables!
View 13 Repliescustomers
phonenumbers
customers_has_phonenumbers
customers -> detailed
customers.customer_id int(11) primary auto_increment
[Code] .....
How to get the data by customers.customer_id from phonenumbers?
I have a problem i need to join two table from different sql servers and as a test i have tried to get data from two table but i realizethe adapter can have only one connection statement as argument how do i get records from two table from diffrent database
Please see my code
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
[code].....
Table 1 has fields: A, B, C, Table 2, there are fields: D, E, F, Table 3 has fields: G, H, I
Connect the condition that A = D and F = I
provide a look at Table A left join B, C of the SQL statement
I have three tables Student, TimeSheet and TimeRecord.
Talbe columns:
Student : StudentId, FirstName,
LastName
TimeSheet: TimeSheetId,StudentId, IsActive
[Code].....
How to Query multiple tables in a dataset to form single consolidated table without using any external database. I know this can be done using 'JOIN' in SQl.
Now my condition is I have multiple tables filled with data in a dataset and each table is interrelated with a common 'column'. For example ,
Table 1
ID
Name
1
[Code].....
Here I mentioned only two tables but in my case there are many tables. I need a generic answer for this dynamic query .
Basically what I'm having to do is create a program that takes a list of CaseIDs and compares them to a table on a remote SQL server. However, the table holding the CaseIDs on the remote server has nearly 120,000 records.
Currently my plan is to query all records on the remote server, save the query and the current list to tables in an Access DB file and then run an outer join to see which CaseIDs have no matching records on the remote server.
I believe this will be a much slower process than I would like. If I could load both queries into arrays or lists in VB and then compare them (therefore, not having to write 120,000 records to a DB file), it would be much faster.
How to JOIN tables on nullable columns? I have following LINQ-query, RMA.fiCharge can be NULL:
Dim query = From charge In Services.dsERP.ERP_Charge _
Join rma In Services.dsRMA.RMA _
On charge.idCharge Equals rma.fiCharge _
Where rma.IMEI = imei
Select charge.idCharge
I get a "Conversion from type 'DBNull' to type 'Integer' is not valid" in query.ToArray():
Dim filter = _
String.Format(Services.dsERP.ERP_Charge.idChargeColumn.ColumnName & " IN({0})", String.Join(",", query.ToArray))
So I could append a WHERE RMA.fiCharge IS NOT NULL in the query. But how to do that in LINQ or is there another option?
The problem was that the DataSet does not support Nullable-Types but generates an InvalidCastException if you query any NULL-Values on an integer-column. The modified LINQ-query from dahlbyk works with little modification. The DataSet generates a boolean-property for every column with AllowDbNull=True, in this case IsfiChargeNull.
Dim query = From charge In Services.dsERP.ERP_Charge _
Join rma In (From rma In Services.dsRMA.RMA _
Where Not rma.IsfiChargeNull
Select rma)
On charge.idCharge Equals rma.fiCharge _
Where rma.IMEI = imei
Select charge.idCharge
How to join two tables in dataset and show in gridview using vb.net 2008?
View 1 RepliesI've found alot of examples for add/edit/delete a single table. In VB6 ADO you could load multiple tables into a recordset using the join command. Then manipulate or modify the data.
I've found how to retreive multiple tables like,
Da = New OleDb.OleDbDataAdapter("Select groups.groupid,groups.userid,lots.groupid,lots.lotid from groups inner join lots on groups.groupid=lots.groupid order by groups.groupid asc", DB) But the only way I have found to update is to use seperate Update commands for each table.
I have three tables: BOOKS(BookID, Title, Author) CLASSES(ClassID, Title, MajorID,BookID) and MAJORS(MajorID, Description). I added these three tables to a LINQ to SQL class (UBooks.dbml) and then connected to the data sources. Then declared DataContext.
Using LINQ, my goal is to display all books in a grid which I have done with:
Dim allBooks = From Books In db.Books _
Order By Books.BookID _
Select Books
Me.BookBindingSource.DataSource = allBooks
Next I need to display all majors in a listbox. I would like the description to be shown however I am only getting the majorID to display with the code
lstMajors.DataSource = db.Majors
I have tried db.Majors.Description, however I am told then that Description is not a member of the LINQ table. and my final goal is to display all the books for whichever Major is selected in another data grid. This is what I am primarily concerned with right now. When using the SQLClient classes, I was able to create a string joining the tables (also had the description properly showing in the listbox, but that is of little importance right now to me). In the video tutorials I was able to watch whenever the tables were dragged from the database into the OR designer of the LINQtoSQL.dbml class file all of the associations were already there and the narrator only really had to do some drag and drop. Not only is drag and drop not working without these associations, but I'd much rather learn the code behind it.
I have two tables as follows:
Customer | Product
------------------
A | Car
A | Bike
A | Boat
[Code].....
If I use a normal JOIN then I get a list of friends for every separate product. I just want the two lists once.
The output lists with '-' need not be table cells, they can be <ul>s.
How can I achieve this? I would like to bind to ASP.net GridView. Should I try to do it all in one query, or use multiple queries and somehow add them both to the same Grid?
Each row actually forms part of a long report. Essentially each row of the report contains Customer ID, a bunch of other fields which match one-to-one with Customer ID, then the two lists for each Customer ID I described. Perhaps I can use a separate query for each list, then manually add each list to the grid on RowDataBound or similar?
i am using ASP.NET with VB.NET to connect to a MS Access database. how can i make the sql statement to insert a new record into the existing table and join tables?
View 1 RepliesI'm working on becoming familiar with LINQ, and getting my head around the syntax and usage.
[Code]...
I have two tables Employees and CafeLogs. Some employees can be cashiers and also customers at the Cafe shop.
Table structures:
Employees: EmployeeId(PK) , FirstName, LastName
CafeLogs: LogId (PK), CashierId, EmployeeId, Value, => CashierId and EmployeeId are the data from column EmployeeId of Empoyee table
Table relationship:
Employees 1:N CafeLogs (CashierId (FK))
[code]....
Right now I know how to select only LogId, Employee's name, and , Value, not with Cashier name yet.
Dim query = From log In db.CafeLogs _
Join emp In db.Employees On emp.EmployeeId Equals log.EmployeeId _
Select log.LogId, emp.FirsName, emp.LastName, log.Value
I am using an Access database to store (filepaths to) pictures as well as comments people can leave on them. One picture can have multiple comments, so the tables look like this:
_____________ _____________
|Photos | |Comments |
|------------| |-------------|
|Id (PK) | |Id (PK) |
|PhotoPath | |PhotoId (FK) |
|Description | |Comment |
|____________| |_____________|
What I need to do now is retrieve a list of all Photos along with their Comments. So I have a class Photo with a collection of Comments:
vb.net
Public Class Photo
Public Property Id As Integer
Public Property PhotoPath As String
Public Property Description As String
Public Property Comments As List(Of Comment) End Class Public Class Comment
Public Property Id As Integer
Public Property PhotoId As Integer
Public Property Comment As String
End Class
I can retrieve the records using an INNER JOIN query (right?), as such;
SELECT Photos.*, Comments.*
FROM (Photos INNER JOIN Comments ON Photos.Id = Comments.PhotoId)
From the result of that, for each row in the result I can create a new Photo instance, set its properties and put it in a List(Of Photo) for further processing (displaying). However, how do I handle the Comments? With this query I would get a lot of duplicate Photos. I'd get a row for each comment, but most of these rows will represent the same photos... How do I handle this the best way? I have used inner join queries before, but only for a one-to-one relationship so I never had this problem before. Now when I finally need a one-to-many relationship I realize I've no idea how to handle this appropriately...
There must be some standard way of handling this? When I previously handled cases like this I didn't use an inner join, I just retrieved all Photos first, then iterate through them and run another query to retrieve the Comments that belong to that Photo (SELECT * FROM Comments WHERE PhotoId = ?). That works fine, but when the tables are getting larger it is getting noticeably slower. So I want to do it in a single query, I definitely want to avoid running hundreds of queries if I can.
[Code]...
What am I doing wrong or do I use a incorrect way to extract text from an array? Using += takes up a lot of computing power when it reaches like 50000 characters so I want a method with much better performance