1function prepareSql()
2 {
3 var numstr = "";
4 var chrstr = "";
5 numstr = numstr + "xed|" + "0" + "^";
6 numstr = numstr + "checkflag|" + "0" + "^";
7 numstr = numstr + "endcheck|" + "0" + "^";
8 numstr = numstr + "fbuilder|" + myform.txtfbuilder.title + "^";
9 numstr = numstr + "ftime|" + document.getElementById("txtftime").options[document.getElementById("txtftime").selectedIndex].value + "^";
10 numstr = numstr + "fexampaper|" + myform.txtfexampapername.title + "^";
11 numstr = numstr.substring(0,numstr.length-1);
12 chrstr = chrstr + "fstime|" + document.all("txtfstime").value + "^" ;
13 chrstr = chrstr + "fetime|" + document.all("txtfetime").value + "^" ;
14
15 chrstr = chrstr + "fdesc|" + document.all("txtfdesc").value + "^" ;
16 chrstr = chrstr + "fname|" + document.all("txtfname").value + "^" ;
17 chrstr = chrstr + "fworkitem|" + document.all("txtfworkitem").value + "^";
18 chrstr = chrstr + "fbak3|" + document.all("txtfbuilder").value + "^" ;
19 chrstr = chrstr.substring(0,chrstr.length-1);
20 if (document.getElementById("action").innerText=="insert")
21 {
22 Insert("0",numstr,chrstr,myform.txtfname.value);
23 }
24 else
25 {
26 Insert(myform.fid.value,numstr,chrstr,myform.txtfname.value);
27 }
28
2 {
3 var numstr = "";
4 var chrstr = "";
5 numstr = numstr + "xed|" + "0" + "^";
6 numstr = numstr + "checkflag|" + "0" + "^";
7 numstr = numstr + "endcheck|" + "0" + "^";
8 numstr = numstr + "fbuilder|" + myform.txtfbuilder.title + "^";
9 numstr = numstr + "ftime|" + document.getElementById("txtftime").options[document.getElementById("txtftime").selectedIndex].value + "^";
10 numstr = numstr + "fexampaper|" + myform.txtfexampapername.title + "^";
11 numstr = numstr.substring(0,numstr.length-1);
12 chrstr = chrstr + "fstime|" + document.all("txtfstime").value + "^" ;
13 chrstr = chrstr + "fetime|" + document.all("txtfetime").value + "^" ;
14
15 chrstr = chrstr + "fdesc|" + document.all("txtfdesc").value + "^" ;
16 chrstr = chrstr + "fname|" + document.all("txtfname").value + "^" ;
17 chrstr = chrstr + "fworkitem|" + document.all("txtfworkitem").value + "^";
18 chrstr = chrstr + "fbak3|" + document.all("txtfbuilder").value + "^" ;
19 chrstr = chrstr.substring(0,chrstr.length-1);
20 if (document.getElementById("action").innerText=="insert")
21 {
22 Insert("0",numstr,chrstr,myform.txtfname.value);
23 }
24 else
25 {
26 Insert(myform.fid.value,numstr,chrstr,myform.txtfname.value);
27 }
28
执行SQL语句时,再将传递过来的字符串进行拆分组装
1 If numstr <> "" Then
2 Cy = Split(numstr, "^")
3 For i = 0 To UBound(Cy)
4 Cytmp = Split(Cy(i), "|")
5 colstr = colstr & Cytmp(0) & ","
6 valuestr = valuestr & Cytmp(1) & ","
7 Next
8 End If
9 If chrstr <> "" Then
10 Cy = Split(chrstr, "^")
11 For i = 0 To UBound(Cy)
12 Cytmp = Split(Cy(i), "|")
13 colstr = colstr & Cytmp(0) & ","
14 valuestr = valuestr & "'" & Cytmp(1) & "',"
15 Next
16 End If
17 colstr = Left(colstr, Len(colstr) - 1)
18 valuestr = Left(valuestr, Len(valuestr) - 1)
19 mySql = " insert into tblexamplanmain (fid," & colstr & ")" & " values(" & maxid & "," & valuestr & ")"
2 Cy = Split(numstr, "^")
3 For i = 0 To UBound(Cy)
4 Cytmp = Split(Cy(i), "|")
5 colstr = colstr & Cytmp(0) & ","
6 valuestr = valuestr & Cytmp(1) & ","
7 Next
8 End If
9 If chrstr <> "" Then
10 Cy = Split(chrstr, "^")
11 For i = 0 To UBound(Cy)
12 Cytmp = Split(Cy(i), "|")
13 colstr = colstr & Cytmp(0) & ","
14 valuestr = valuestr & "'" & Cytmp(1) & "',"
15 Next
16 End If
17 colstr = Left(colstr, Len(colstr) - 1)
18 valuestr = Left(valuestr, Len(valuestr) - 1)
19 mySql = " insert into tblexamplanmain (fid," & colstr & ")" & " values(" & maxid & "," & valuestr & ")"