append on asp page

Results 1 to 2 of 2

Thread: append on asp page

  1. #1
    Join Date
    Dec 1969

    Default append on asp page

    I am writting an insert stored procedure in mssql.<BR>It will be / or should be (it is a medical form) about 150 fields of which at least 100 are required.<BR>So the user will be inputting all required fields ( plus those which are not required, if necessary)<BR>So I was thinking if there is a way instead of writing 100-150 APPEND statements on asp page to LOOP them?<BR>Thanks,<BR>Rudi<BR>The below code I would have on my asp page.<BR>&#060;%<BR>set dataConn = Server.CreateObject("ADODB.Connection")<BR>dataCon n.Open "DSN=webData;uid=user;pwd=password"<BR>Set adocmd = Server.CreateObject("ADODB.Command")<BR>adocmd.Com mandText = "sp_MyProc"<BR>adocmd.ActiveConnection = dataConn<BR>adocmd.CommandType = adCmdStoredProc<BR>adocmd.Parameters.Append adocmd.CreateParameter<BR>("username",adVarChar, adParamInput, 16, _<BR>Request.Form("UserName"))<BR>.........<BR>ado cmd.Execute<BR>%&#062;<BR>

  2. #2 Guest

    Default RE: append on asp page

    You can loop through the form variables and put each into a db field:<BR><BR>&#060;%<BR>dim fld, rs<BR>&#039setup and open your recordset here and goto required record or addnew<BR><BR>for each fld in rs.Fields<BR>&nbsp;&nbsp;&nbsp;if request.form( &#060;&#062; "" then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fld.value=request.form(<BR>&nbsp;&nbsp;&n bsp;end if<BR>next<BR>rs.update<BR>%&#062;<BR><BR>This goes through each of the fields in the recordset row and if there is a form field of the same name,that contains data it sets the database field to that value, and then updates the record. <BR><BR>You would probably need to do some kind of processing to make sure that number fields don&#039t get text and datefields get valid dates.<BR><BR>You would probably have to perform some kind of clientside form validation before submitting the form, and you would have to make sure that the form fields are named the same as the matching DB fields.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts