Dynamic array in VB/VB.NET/ASP
Time to go back to old school ASP, I found that i need to create an array that contains a list of languages from a table in database. I would like to make this array length as many as the number of rows in language table. yes you can do it through keyword of ReDim and Preserve
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <% dim objLanguage dim languageCount dim languageArray() languageCount = 0 set objLanguage = Server.CreateObject("ADODB.Recordset") objLanguage.ActiveConnection = MM_CTG_STRING objLanguage.Source = "SELECT * FROM Languages" objLanguage.CursorType = 0 objLanguage.CursorLocation = 2 objLanguage.LockType = 3 objLanguage.Open() WHILE NOT objLanguage.EOF response.Write("<td><p class='fieldTitle'>") response.Write(objLanguage("Language")) response.Write("</p></td>") ReDim Preserve languageArray(languageCount) languageArray(languageCount) = objLanguage("LanguageID") languageCount = languageCount + 1 objLanguage.MoveNext() WEND objLanguage.Close() Set objLanguage = nothing %> |
Posted: August 29th, 2008 under .NET, Others, VB.NET.
Tags: Array, ASP, ASP.NET, VB, VB.NET