Welcome to WebmasterWorld Guest from 54.226.241.8

Forum Moderators: open

Message Too Old, No Replies

Data Retrieve From msSQL DB

msSQL

     

stoneintexas

7:56 am on Dec 1, 2010 (gmt 0)



For all of you experts out there in programming world - I am not a programmer but I have a need to pull some data from a msSQL Database.

Please help...

Here is my code and what I am wanting is this: Two tables with a common UserID / bUserID field.

I want to pull data from one table based on the other and display that data like below: what I keep getting is bob repeating three times along with his three entries - same for mike and jerry

1 Bob < Table1 field identifier is UserID which is 1 in Bobs case - Bob has three entries in the other table same as Mike and Jerry
Entry One < From Table2 - coresponding field name is bUserID
Entry Two < From Table2 - coresponding field name is bUserID
Entry Three < From Table2 - coresponding field name is bUserID

2 Mike < Table1
Entry One < From Table2 - coresponding field name is bUserID
Entry Two < From Table2 - coresponding field name is bUserID
Entry Three < From Table2 - coresponding field name is bUserID

3 Jerry < Table1
Entry One < From Table2 - coresponding field name is bUserID
Entry Two < From Table2 - coresponding field name is bUserID
Entry Three < From Table2 - coresponding field name is bUserID


code:

<!-- #include file="db.asp" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM bBlog"
rs.Open SQL, oDB,1,3
%>
<%
bUserID=rs("bUserID")
set rs1= server.createobject("adodb.recordset")
sql="SELECT * from TblUsers where UserID="&bUserID
rs1.Open sql, ConString,1,3
%>
<Table border=0 cellpadding=4 cellspacing=1 bgcolor="#006666" width="100%">
<tr>
<td nowrap>
<p align="center"><font color="#FFFFFF" size="2"><b>Blog</b></font>
</td>
</tr>
<% do until rs1.EOF%>
<tr bgcolor="#FFFFFF">
<td valign="top">
<p align="left"><b><%=rs1("Username")%></b>
<%
UserID=rs1("UserID")
Set conn= Server.CreateObject("ADODB.Connection")
Set rs2 = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM bBlog where bUserID="&UserID&"order by bDateAdd DESC"
rs2.Open SQL, oDB,1,3
do until rs2.eof
%>
<br>
<%=rs2("bTitle")%>
<%rs2.MoveNext
loop
RS2.Close
%>
</td>
</tr>
<%
rs1.MoveNext
loop
%>
</table>
 

Featured Threads

Hot Threads This Week

Hot Threads This Month