Set rsTeam = Server.CreateObject("ADODB.Recordset")
sql1 = " SELECT Team_Id, Team_Name, Groups_League_Id, Groups_League_Name FROM Racing_Team "
rsTeam.open sql1, MM_Conn_STRING,1,3
Do while Not rsTeam.EOF
Set rsGroups_League = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * FROM Groups_League Where Groups_League_Id ='"&rsTeam("Groups_League_Id")&"' "
rsGroups_League.open sql2, MM_Conn_STRING,1,3
if rsGroups_League.EOF then
rsGroups_League.addnew
rsGroups_League("Groups_League_Id") = rsTeam("Groups_League_Id")
rsGroups_League("Groups_League_Name") = rsTeam("Groups_League_Name")
rsGroups_League.update
end if
rsGroups_League.Close
Set rsGroups_League = Nothing
rsTeam.MoveNext()
LOOP
rsTeam.Close
Set rsTeam = Nothing
ขอตัวอย่าง code นี้ในภาษา asp.net(vb) หน่อยนะครับ ของเดิม asp classic
sql1 = " SELECT Team_Id, Team_Name, Groups_League_Id, Groups_League_Name FROM Racing_Team "
rsTeam.open sql1, MM_Conn_STRING,1,3
Do while Not rsTeam.EOF
Set rsGroups_League = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * FROM Groups_League Where Groups_League_Id ='"&rsTeam("Groups_League_Id")&"' "
rsGroups_League.open sql2, MM_Conn_STRING,1,3
if rsGroups_League.EOF then
rsGroups_League.addnew
rsGroups_League("Groups_League_Id") = rsTeam("Groups_League_Id")
rsGroups_League("Groups_League_Name") = rsTeam("Groups_League_Name")
rsGroups_League.update
end if
rsGroups_League.Close
Set rsGroups_League = Nothing
rsTeam.MoveNext()
LOOP
rsTeam.Close
Set rsTeam = Nothing