Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing public variables with VBScript subroutines
Message
 
 
À
27/05/2003 14:48:11
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00793216
Message ID:
00793344
Vues:
86
Hi Jackson,

You should not declare the form's code as sub (e.g. remove SUB TEST_sys_edit declaration and do it straight) Variables defined in one sub are not visible in another. If you define them outside SUB declaration they would be visible. Also you can pass variables into sub (I usually prefer functions) via parameters.

>This is my first time using VBscript to create a user inferface and to add a record into an Access database. The problem I'm having is that the data fields entered by the user from subroutine(TEST_sys_edit) which are stored into public variables (P_idnumber, P_sysname, P_type, P_bacfreq, P_population, P_status) are NOT being passed into subroutine(ADD_system) even though is contains the correct user entered data from (TEST_sys_edit). Does anyone know how to access these variables outside(TEST_sys_edit)?
>Thanks.
>
>Jackson
>
><%
>SUB ADD_system
>'***** add a record with data with values from public P_ variables.
>
>strDBPath = Server.MapPath("newbac.mdb")
>Set cnnSearch = Server.CreateObject("ADODB.Connection")
>cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
>
>strSQL = "INSERT INTO bac_msis (idnumber,sysname,type,bacfreq,population,status)"
>strSQL = strSQL & " VALUES "
>strSQL = strSQL & "('" & P_idnumber & "',"
>strSQL = strSQL & "'" & P_sysname & "',"
>strSQL = strSQL & "'" & P_type & "',"
>strSQL = strSQL & "'" & P_bacfreq & "',"
>strSQL = strSQL & "'" & P_population & "',"
>strSQL = strSQL & "'" & P_status & "')"
>cnnSearch.Execute strSQL
>cnnSearch.close
>
>END SUB
>
>
><%
>'*****************************************************
>SUB TEST_sys_edit
>
>If Request.Form.Count <> 0 And dictFields.Count = 0 Then
>	
>	<B>GOOD ENTRY!</B><BR>
>
><FORM ACTION="<%= Request.ServerVariables("Script_Name")   ?action=ADD_system" METHOD="post" >
><%
>
>'**WHY does it not pass out of this routine but do get assigned here?
>P_id = Request.Form("id")
>P_idnumber = Request.Form("idnumber")
>P_sysname = Request.Form("sysname")
>P_type = Request.Form("type")
>P_bacfreq = Request.Form("bacfreq")
>P_population =	Request.Form("population")
>P_status = Request.Form("status")	
>'********************************************************************
>  	
><br><hr>
><INPUT TYPE="submit" VALUE="Save Data "></INPUT><BR>
></FORM>
><%
>END sub
>  
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform