|
sorry buddys it might be in wrong category, but i use ASP.NET platform
for devloping so...
now my question:
i have table formated as three column:
id,parent_id,name
ex..
id /parent_id /name
1 /null /ABC1
2 /1 /ABC2
3 /1 /ABC3
4 /2 /ABC4
5 /4 /ABC5
6 /3 /ABC6
for example i wnt to retrive perticulars child and sub child of id 2 then
it should give result:
2 /1 /ABC2
4 /2 /ABC4
5 /4 /ABC5
actually i want perticulars child and sub childs.. if id is 2 den i want child of id 2, and sub childs of id 2,s child and so on..
Please giv me appropriate query for it...
thanks in advance
modified on Wednesday, August 19, 2009 2:58 AM
|
|
|
|
|
Can you expl more because what you asking and what your result is doesnt make sence.
|
|
|
|
|
actually i want perticulars child and sub childs.. if id is 2 den i want child of id 2, and sub childs of id 2,s child and so on..
|
|
|
|
|
sorry, this is wrong forum... if you post you question in a appropriate forum you will be clearly guided by our experts.....
|
|
|
|
|
Since you asked about query, here is a possible implementation using stored procedure.
1 - Write a stored procedure that takes a parent id.
2 - Do a select to get all the children of the supplied parent id and assign it to a T-SQL cursor.
3 - Iterate over all of the children.
3.1 - Add row into a temporary table
3.2 - Call this procedure again (recursive) by passing the child id as parent id. Goes to step 2
4 - Select all the rows from the temporary table if @@NESTLEVEL is 1.
5 - Drop temporary table, de-allocate cursor.
Note: SQL server has a stored procedure nesting limit. I guess it is 32. So if you have an item which is nested more than 32 levels, you will get error. In such case, you need to handle this in the application code rather than on a procedure.
Also you need to make sure that the temporary table is getting created only once, that is when the procedure starts executing for the first time. All the nested calls will get the temporary table created on the first call.
This can be done in a better way using C# (or whatever language you use).
|
|
|
|
|
ok... i understand ur method, but i faced problem to create procedure.. can you reply me demo procedure???
thanks..
|
|
|
|
|
punit_belani wrote: but i faced problem to create procedure
What problem are you facing in creating a procedure?
punit_belani wrote: can you reply me demo procedure
Its very easy to create your own procedure with the steps provided in my last post. If you have problems, come back with specific error messages. Do a search on creating nested stored procedures and learn to do it yourself. Spoon feeding will not benefit you.
|
|
|
|
|
you mean you need hierarchical data. If particular node is chosen, you need all its child elements.
I think it is very easy to do in Recursion, but very tough to do it in a single SQL.
Try it, It needs Self joins in query. I will do this when get time and let you know.
|
|
|
|
|
ok.. waitin for ur reply.. thanks..
|
|
|
|
|
m looking to get the value of label or hidden input field in javascript ....
<javascript>
var lbl = document.getElementById(Label1);
.
.
so.addParam('flashvars', 'file=' + lbl.value + '&type=video');
.
.
>
where Label1 is
or
<asp:label id="Label1" runat="server" text="NeverEndingSunAviHochberg.flv" visible="False" ><="" asp:label="">
but i m not geeting it right
any help.........
thanks in advance
|
|
|
|
|
You need to use the ClientID property of Label1 to find out what it's called on the client
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
u meanz.
var lbl = document.getElementById(<%=title.ClientID>').value;
but still not working
|
|
|
|
|
Well, that's because you have not put the id in quotes.
When you move beyond making the sort of basic mistakes that are clear to anyone with half a clue, you will find it hard to get answers if you don't move past 'still not working', to actually explain any error messages, what you did about those messages, and why you're still stuck.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
not at all actually its just typing mistake.
in js..
var lbl = document.getElementById('<=title.ClientID>;').value;
title is..
;
|
|
|
|
|
AhmedNisar82 wrote: var lbl = document.getElementById('<=title.ClientID>;').value;
This won't work, just < and > does not make a server side tag. You need to put a % inside either side for that to work. Have you checked the HTML to see what comes out ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi all,
I want to drag and drop items from one listbox to another listbox on the same webform. Do anybody have an idea of how to do this in ASP.net?
|
|
|
|
|
There is no way that ASP.NET can help you, you want to do something that requires the use of javascript.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi
I don't know much about javascript. Can anybody tell me how to do the above problem in javascript. Thanks in advance.
|
|
|
|
|
hello,
i allready know i can use web service by either calling a function with no postback and with postback , for example : 'void helloworld' for a no postback and 'int maxnum' with a feedback.
is there a way to use the webservice as an event triggered?
for example if i want to get an event triggered in my application from a webservice every time a new user logs into my website can i do it using web service ?
tnx in advance
avi
|
|
|
|
|
No, obviously not. Because your app knows where the webservice is, the webservice does not know where your app is. And, given that it's a web app, there's no way a webservice could call it, because if it did, it would call the server, and you'd have no way to refresh the client as a result.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
now lets say what if a web service has to 'think' about the answer to my query for more than a minute , will i have to 'stay put' and wait for the answer ? cant i get a notice that the answer is ready for me to pick it up without 'nagging' it every once and awhile ?
|
|
|
|
|
You can make an asyncronous call, that's what AJAX is all about.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am trying to integrate paypal pro in my website but paypal pro is supporting only USD . In my site i am using indian rupees how to convert Indian rupess to USD according to the current exchange rate.
Thanks in advance
viswesh.
|
|
|
|
|
Find a webservice that offers the current exchange rate. Your only other option is to set it manually on a daily basis.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
is there any webservice to integrate in my website ?
|
|
|
|