0

I am currently working on a website where we can track small event for our clients. I am using linq-to-sql and asp.net to build it. So far the site is really small about 10 pages, and only 2 tables, events and clients. I have listed the columns for each table below:

Events: -eventid -eventname -datecreated -details -datedue -status -clientname (this should be clientid) -sentemail Clients: -clientid -clientname -clientemail -clientphone 

the issue I am having is getting the 2 database tables* to work together. Ideally I would like to have clientname replaced with clientid in the Events table.

I had it set up this way before but ran into an issue when listing out the events:

When I am listing out the events I would like it to show the client name as appose to the clientID. Unfortunately I am pretty new to ASP.net and although I could easily do it in PHP have no idea how to get it to work. Its not a huge deal but I would like to be able to update the client list and events apart from one another.

Sorry If this makes little to no sense, If there is any confusion I will try to word it better.

*correction on my part

4
  • Are the tables stored in separate databases? I'm confused with the statement "the issue I am having is getting the 2 databases to work together..." If Events and Clients are two database tables in 1 database the solution is easy. Commented Aug 3, 2011 at 20:43
  • Could you add any info on what you've tried exactly and what you've experienced that's different than what you would like to happen? Commented Aug 3, 2011 at 20:47
  • are they 2 different databases or 2 different tables in a single database Commented Aug 3, 2011 at 20:47
  • sorry just 1 database 2 tables, I don't know whey I stated it that way, must have been late last night >< Commented Aug 4, 2011 at 13:43

2 Answers 2

2

Once you've got your database normalized, create a Linq2Sql context, and then you can write a query similar to this (to get a list of event names and their client names):

var results = from e in dbContext.Events join c in dbContext.Clients on e.clientid equals c.clientid select new { e.eventname, c.clientname }; 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the response I will try this once I finish setting it back to use Ids
1

in addition to the answer of Andrew Lewis you need to:

1) add the clientid field to the events table

2) run a sql query to fill the clientid field:

update events set clientid = (select clientid from client where name = events.clientname) 

3) remove the clientname field from the events table

1 Comment

Thank you for the response this should make switching it back much easier

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.