beccatigger Posted August 16, 2006 Posted August 16, 2006 Hiya,Having considerable trouble due to my inexperience with asp. I don't have time to learn php so that's out.Basically I've got a Company table and a customer type table, and a customer types table (link table)Where customer types has the primary keys from the other tables: company type and companyI've made a customer details edit form where you can change all their details in one form so you can edit data from any tables.When you edit their customer types it'll show checked checkboxes where the customertype from customertypes and the customernumber matches the customer type in Customertype tableSo you got it a bit like this:[x] Type 1 Customer[ ] Type 2 Customer[x] Type 3 customer[x] type 4 customerOK so what I'm trying to do is compare the values of the checkboxes and if they've changed then delete or insert the values into customertypes as necessary.I tried to do it with the command function (cos you can't use their insert / delete record thing more than once) in DW but it won't pull the variables out for some reason. Also it doesn't seem to like me having more than one variable.Anyway here's the section of code (command deleted cos it just kept saying it was wrong):<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><!--#include file="Connections/conn2.asp" --><%Dim Recordset1__CNRecordset1__CN = "1"If (Request.Form("CompanyNumber") <> "") Then Recordset1__CN = Request.Form("CompanyNumber") End If%><%Dim Recordset1Dim Recordset1_numRowsSet Recordset1 = Server.CreateObject("ADODB.Recordset")Recordset1.ActiveConnection = MM_conn2_STRINGRecordset1.Source = "SELECT * FROM SelectCusType WHERE CompanyNumber=" + Replace(Recordset1__CN, "'", "''") + ""Recordset1.CursorType = 0Recordset1.CursorLocation = 2Recordset1.LockType = 1Recordset1.Open()DO WHILE NOT Recordset1.EOF IF x <> total THEN CusType = CusType & Recordset1.Fields.Item("Number").Value & "," ELSE CusType = CusType & Recordset1.Fields.Item("Number").Value END IF x = x + 1Recordset1.MoveNextLOOPRecordset1_numRows = 0%><%Dim Recordset2Dim Recordset2_numRowsSet Recordset2 = Server.CreateObject("ADODB.Recordset")Recordset2.ActiveConnection = MM_conn2_STRINGRecordset2.Source = "SELECT * FROM Company"Recordset2.CursorType = 0Recordset2.CursorLocation = 2Recordset2.LockType = 1Recordset2.Open()Recordset2_numRows = 0%><%Dim Recordset3Dim Recordset3_numRowsSet Recordset3 = Server.CreateObject("ADODB.Recordset")Recordset3.ActiveConnection = MM_conn2_STRINGRecordset3.Source = "SELECT * FROM [Customer Type] ORDER BY Number"Recordset3.CursorType = 0Recordset3.CursorLocation = 2Recordset3.LockType = 1Recordset3.Open()Recordset3_numRows = 0%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = -1Repeat1__index = 0Recordset1_numRows = Recordset1_numRows + Repeat1__numRows%><%Dim Repeat2__numRowsDim Repeat2__indexRepeat2__numRows = -1Repeat2__index = 0Recordset3_numRows = Recordset3_numRows + Repeat2__numRows%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form name="crap" > <input type="text" name="ComNum" value="<%=(Recordset2.Fields.Item("CompanyNumber").Value)%>"> <% While ((Repeat2__numRows <> 0) AND (NOT Recordset3.EOF)) %> <input type="checkbox" name="ctcheckbox" value="<%=(Recordset3.Fields.Item("Number").Value)%>" <% If instr(CusType,Recordset3.Fields.Item("Number").Value) > 0 Then Response.Write("Checked") %>> <%=(Recordset3.Fields.Item("Customer Type").Value)%> <br> <% Repeat2__index=Repeat2__index+1 Repeat2__numRows=Repeat2__numRows-1 Recordset3.MoveNext()Wend%> <input type="submit" value="go"></form></body></html><%Recordset1.Close()Set Recordset1 = Nothing%><%Recordset2.Close()Set Recordset2 = Nothing%><%Recordset3.Close()Set Recordset3 = Nothing%>Now I'm assuming I've got to do some comparison of the values in the table and then if they#'re different, insert or delete, is this correct?Any help would be muchly appreciated as I've wasted too many hours battling against DW and ASP!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now