Replay Multi insert
I use WADataAssist205
My steps
I first make the table inside a form.
Make sure it was working
Then applied the repeat selection.
Then I selected multi Insert from DataAssist and use the dropdown to select to appropiate colums where to insert
When running the page again I get an string error from the WA_loopedFields
The problem was the last %> in every record added so I changed this to &premil;> then it worked okay but nothing was inserted into the database.
I tryed to make a insert page with dataAssist
Very simple insert.
But it will not work, i get an error
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near '34'.
/DressForm_Insert.asp, line 31
<%
' WA Application Builder Insert
if (cStr(Request.Form("Insert.x")) <> "") then
WA_connection = MM_vbOFM_STRING
WA_table = "dbo.DressForm"
WA_sessionName = "WADA_Insert_dboDressForm"
WA_redirectURL = "DressForm_Results.asp"
WA_keepQueryString = true
WA_indexField = "MeasuementID"
WA_fieldNamesStr = "ContactpersoonId|Number|Name|34|Grading1|36|Grading2|38|Grading3|40|Grading4|42|Grading5|44|Grading6|46|Grading7"
WA_fieldValuesStr = "" & cStr(cStr(Request.Form("ContactpersoonId"))) & "" & "|" & "" & cStr(cStr(Request.Form("Number"))) & "" & "|" & "" & cStr(cStr(Request.Form("Name"))) & "" & "|" & "" & cStr(cStr(Request.Form("34"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading1"))) & "" & "|" & "" & cStr(cStr(Request.Form("36"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading2"))) & "" & "|" & "" & cStr(cStr(Request.Form("38"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading3"))) & "" & "|" & "" & cStr(cStr(Request.Form("40"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading4"))) & "" & "|" & "" & cStr(cStr(Request.Form("42"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading5"))) & "" & "|" & "" & cStr(cStr(Request.Form("44"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading6"))) & "" & "|" & "" & cStr(cStr(Request.Form("46"))) & "" & "|" & "" & cStr(cStr(Request.Form("Grading7"))) & ""
WA_columnTypesStr = "none,none,NULL|none,none,NULL|',none,''|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL"
WA_comparisonStr = " = | = | LIKE | = | = | = | = | = | = | = | = | = | = | = | = | = | = "
WA_fieldNames = Split(WA_fieldNamesStr,"|")
WA_fieldValues = Split(WA_fieldValuesStr,"|")
WA_columns = Split(WA_columnTypesStr,"|")
WA_comparisions = Split(WA_comparisonStr, "|")
insertParamsObj = WA_AB_generateInsertParams(WA_fieldNames, WA_columns, WA_fieldValues, -1)
set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = WA_connection
MM_editCmd.CommandText = "INSERT INTO " & WA_table & " (" & insertParamsObj(1) & ") VALUES (" & insertParamsObj(2) & ")"
MM_editCmd.Execute()
MM_editCmd.ActiveConnection.Close()
obj = WA_AB_generateWhereClause(WA_fieldNames, WA_columns, WA_fieldValues, WA_comparisions)
sqlstr = "SELECT " & WA_indexField & " FROM " & WA_table & " WHERE " & obj & " ORDER BY " & WA_indexField & " DESC"
set WA_AppBuilderRecordset = Server.CreateObject("ADODB.Recordset")
WA_AppBuilderRecordset.ActiveConnection = WA_connection
WA_AppBuilderRecordset.Source = sqlstr
WA_AppBuilderRecordset.CursorType = 0
WA_AppBuilderRecordset.CursorLocation = 2
WA_AppBuilderRecordset.LockType = 1
WA_AppBuilderRecordset.Open()
if (NOT WA_AppBuilderRecordset.EOF) then Session(WA_sessionName) = WA_AppBuilderRecordset.Fields.Item(WA_indexField).Value
WA_AppBuilderRecordset.Close()
if (WA_redirectURL <> "") then
if (WA_keepQueryString AND Request.QueryString <> "" AND Request.QueryString.Count > 0) then
if (inStr(WA_redirectURL,"?") > 0) then
WA_redirectURL = WA_redirectURL & "&"
else
WA_redirectURL = WA_redirectURL & "?"
end if
WA_redirectURL = WA_redirectURL & Request.QueryString
end if
Response.Redirect(WA_redirectURL)
end if
end if
%>
So then I tryed the wizard from dreamweaver and also the same simple form
This one works perfectly
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
for i=0 to 4 step 1
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_vbOFM_STRING
MM_editCmd.CommandText = "INSERT INTO dbo.DressForm (ContactpersoonId, [Number], Name, [34], Grading1, [36], Grading2, [38], Grading3, [40], Grading4, [42], Grading5, [44], Grading6, [46], Grading7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("ContactpersoonId"), Request.Form("ContactpersoonId"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("Number"), Request.Form("Number"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 200, Request.Form("Name")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 10, Request.Form("Element")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 10, Request.Form("Grading1")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 10, Request.Form("Element2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 10, Request.Form("Grading2")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 10, Request.Form("Element3")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 10, Request.Form("Grading3")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 10, Request.Form("0")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 10, Request.Form("Grading4")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202, 1, 10, Request.Form("Element4")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202, 1, 10, Request.Form("Grading5")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202, 1, 10, Request.Form("Element5")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202, 1, 10, Request.Form("Grading6")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 202, 1, 10, Request.Form("Element6")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 202, 1, 10, Request.Form("Grading7")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
next
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "Results.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
I am using sql 2008 and this script works perfect
INSERT INTO
dbo.DressForm
( ContactpersoonId, Number, [Name], [34], Grading1, [36], Grading2, [38], Grading3,
[40], Grading4, [42], Grading5, [44], Grading6, [46], Grading7)
VALUES (3,0,'Test1',1,2,1,0.5,12,2,100,4,104,2.25,106.25,2,108.25,0.75),
(3,1,'Test2',1,2,1,0.5,12,2,100,4,104,2.25,106.25,2,108.25,0.75),
(3,2,'Test3',1,2,1,0.5,12,2,100,4,104,2.25,106.25,2,108.25,0.75);
The problem is I need to replace the values with a variable so I can use the form that I have and insert mutliple records using a loop but what ever I try have no luck so far.