I'm new to .net programming, in which I'm attempting to code a hardware inventory web app. I'm using Linq to SQL Classes.
I have three SQL 2005 tables.
In each table there's a tblID master key (auto increment). Created master/foreign keys (TblEmployee's tblID is the master key and tblDesktop, tblHardware are foreign keys).
I'm utilizing the following code obtained from asp.net site:
Partial Class _Default
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim db As New AssetsDBDataContext
Dim q = From b In db.tblEmployees _
Where b.LastName.Contains(txtSearch.Text.Trim()) _
And b.FirstName.Contains(txtSearch1.Text.Trim()) _
lv.DataSource = q
How it works: To see all hardware an employee is assigned with - Enter the employee's last and/or first name in the search boxes.
I successfully get results, but I would like to optimize the search/database.
Problem: I'm using tblID for the primary keys (auto increment) with relationships to the other tables.
I dont want to add duplicate hardware in the tables if they already exists.
Example: tblDesktop contains three columns - Manufacture, Model, and Serial.
Is there away to link the tblEmployee table to the hardware tables - yielding the desired search results?
Maybe: join tblEmployee, tblDesktop, tblLaptop to a new table (displaying all three data)?