| Author |
Topic |
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-03 : 17:23:46
|
| I have two tablesTermID, Term1--- Abc2--- Test4--- Tunicand TermID, RelatedTermID1 --- 21--- 42--- 4I need to get back something like thisTermID, Term, RelatedTermsInformation1--- test--- test,tunic#1,4 that above was my solution, get the relatedterms information and comma separate, and then put a # and get all the ids comma separate them and then put the in one field. then I can later parse it in the client this does not seem like a very good solution ( or is it?) If posible it would be nice to get something like thisTermID, Term, RelatedTermsInformation1 test RelatedTermsTwoDimentionalArray but I am not sure how this idea could be implemented using the capabilities of SQL. my other option is have the client make one call to the database to get the terms and then lots of another calls to get the relatedTerms, but that will mean one trip to the DB for the list term, and one call for every single term found.any ideas in how to make this better ? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-03 : 18:19:32
|
| join them together, get all in ine call and parse the thing at the client. it's what it's there for.if you're working with ado.net you can just return 2 recordsets and have a master child relationship by default.just have your stored procedure return 2 selects._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-03 : 18:30:31
|
| so far I have call a stored procedure but only expecting one record set, I am not sure how to handle two, could you point me to some sample online ?. I tried googling but i am not sure I understand it correcly this is how I have been calling my SP so farpublic DataView GetRelatedTerm_SeeAlso(int TermID) { try { DB data = new DB List<DbParameter> paramlist = new List<DbParameter>(); paramlist.Add(data.CreateParameter("@TermID", TermID)); return data.FetchDataSet("dbo.Glossary_Fetch_Terms_AND_RELATED_TERMS", ref paramlist).Tables[0].DefaultView; } catch { throw; } } |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-03 : 18:42:06
|
| ya that is enterprise library .. and i am just starting to touch it .... it is a rought ride... it is supposed to make things better but until learning what it can do ...even simple things seems harder |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-03 : 18:46:47
|
good luck! _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-03 : 19:14:51
|
| spirit1, I figure out how to use two record sets with enterprise library, so I am following your suggestion, so I join the tables Select * from Terms join TermsRelated ON Terms.ID = TermsRelated.IDbut i am still unsure on what should my selects be to make two record sets ? |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-03 : 19:23:04
|
| Select *from TermsSelect TR.*from Terms Tjoin TermsRelated TR ON TID = TR.IDalso specify column names instead of the *_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-03 : 19:28:52
|
| got it thanks |
 |
|
|
|