各位请帮忙…用array 做sql 的句子…
artai 2002-01-02 12:19:41 The array ‘strCls_id’ now is assigned (30) size but I want to use the ‘i’ that count by the recordset ‘rstClsPart’ to assigned to the array‘strCls_id’ but vbscript not allowed since it is variable not constant .
How can I do?
<%
Set cnnDB = Server.CreateObject("ADODB.Connection")
StrCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./MainV1.1.mdb")
cnnDB.Open StrCon '-----Open the database-----
Set rstClsPart = Server.CreateObject ("ADODB.Recordset")
'-----get the Class Part table-----
'-----get the cls_id (class that the lecturer teach)------
SQL_ClsPart_clsid = "SELECT cls_id FROM [Class Part] WHERE lect_id='00013' ORDER BY cls_id ASC"
rstClsPart.Open SQL_ClsPart_clsid,cnnDB
dim i
i=0
%>
<p> </p>
<p>
<SELECT size=12 ID=SelectCls>
<%
'-------Count the number of the required class--------
Do While Not rstClsPart.EOF
i=i+1
rstClsPart.MoveNext
Loop
'-------Write the list about the class that the lecturer teach-------
rstClsPart.MoveFirst
i=i-1 '----start from zero condition-----
dim strCls_id(30)
For num = 0 to i
%>
<OPTION value=<%=rstClsPart("cls_id")%>>
<% strCls_id(i)=rstClsPart("cls_id")
Set rstCls = Server.CreateObject ("ADODB.Recordset")
'-------Using the cls_id to get the cos_id and cls_desp in class table------
SQL_Cls_all = "SELECT * FROM Class WHERE cls_id ='"&strCls_id(i)&"'"
rstCls.Open SQL_Cls_all,cnnDB
'-------Write class in the list-----
Response.Write(rstCls("cos_id")&"/"&rstCls("cls_desp"))
rstCls.Close
Set rstCls = Nothing
%>
</OPTION>
<%
rstClsPart.MoveNext
Next
rstClsPart.Close
Set rstClsPart = Nothing
cnnDB.Close
Set cnnDB = Nothing
%>
</SELECT></p>