Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2005
    Posts
    8

    Question Unanswered: Dynamic Query for web page

    I want to create a query for 12 tables. coz all tables have comman fields and condition is also same. See code below......

    '''''making array of tables
    arr_detail=split("delhi,kol,banglore,ahmd,chennai, hyd,mumbai,tvm,pun e,foreign,courier_national,courier_mumbai,courier_ delhi",",")


    if detail=1 then
    for i=lBound(arr_detail) to UBound(arr_detail)
    str_detail= str_detail & "select * from "& arr_detail(i) &" where itemid='" & itemid &"'^"
    next

    '''''''making array of Query
    arr_str = Split(str_detail,"^")


    for i=lBound(arr_str) to UBound(arr_str)-1
    ' Response.Write "<br>"& arr_str(i)
    set rs_detail =Server.CreateObject("ADODB.RecordSet")
    rs_detail.Open arr_str(i),connview, adOpenStatic, adLockOptimistic
    %>
    <tr>
    <%

    do while not rs_detail.EOF
    %>
    <tr>
    <%
    for k=0 to rs_detail.Fields.count-1
    if isnull(rs_detail(k)) or trim(rs_detail(k))=""or trim(rs_detail(k))="--" then %>
    <td>&nbsp;</td>
    <%
    else
    %>
    <td><%=rs_detail(k)%></td>
    <% end if %>

    <%
    next
    %></tr><%
    rs_detail.MoveNext
    loop
    Response.End
    rs_detail.Close
    set rs_detail=nothing
    next
    Last edited by eksanjay; 01-12-06 at 00:58. Reason: Problem solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •