Question : using <br> in sql statements from asp

Hi All,

I have a list of about 100 lines that were each created as seperate forms before. However this is not very user friendly reloading the page for each change. So i have created a form around the whole thing that numbers each tag with a unique number. Then when the page reloads it loops through the records from 1 to the total number of records and builds a large update query.

From what i have researched to do a multiple update i have to do:

Update table set field = 'value' where field ='value
go
Update table set field = 'value' where field ='value
go
Update table set field = 'value' where field ='value

I have created the sql query based on this and then i do a response.write to see the results
this comes out fine and i have copied it into sql and run the query there to check it works. However to get the desired effect above i have added <br> into the sql statement to create the line breaks as go doesnt work if placed at the end of the line.

when running this through i get the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '<'.

When i response.write on the command text it shows that it fails after the last record. However for the last record it doesnt write further<br> as it knows there is not another update after that.

So after all that background the question is how can i use line breaks in the sql statement without getting the syntax error. Or is there another way to achieve updating multiple SQL rows in a table based on any number of rows and content

I have attached the code snippet.

Any help on this would be greatly appreciated and if there is anymore information i can provide to help please let me know.

Kind Regards

Sprog

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
<%totalrecords = request.form("totalrecords")

' use i as a counter

For i=1 to totalrecords	   
  
recordname = "Getcats" + Cstr(i)
workcodename = "workcode" + Cstr(i)

if i = totalrecords then

updatequery = updatequery + "Update Nu_KPI_Catagories Set Paul = '"+request.form(recordname)+"' Where WW_Code = '"+request.form(workcodename)+"' and SiteID ='PE'"
else
updatequery = updatequery + "Update Nu_KPI_Catagories Set Paul = '"+request.form(recordname)+"' Where WW_Code = '"+request.form(workcodename)+"' and SiteID ='PE' <br> go <br>"
end if 

next     
'repeat the code and move on to the next value of i


'once the query is built execute it
if totalrecords <> "" then 

Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_Nu_KPI_STRING
    MM_editCmd.CommandText = updatequery
	response.write(MM_editCmd.commandtext)
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

end if 
%>

Answer : using <br> in sql statements from asp

Founded solution is very creative, but by default the files will be saved in (or loaded from) applications folder therefore
   ExtractFilePath(Application.ExeName)    is   unnecessary.
Random Solutions  
 
programming4us programming4us