CMS Traffic Systems Ltd. - Traffic Solutions
<%
if session("userid1")="" then
Response.Redirect "Login.asp?page=UploadReach"
end if
Function ReplaceName(Name)
Dim LeftStr , RightStr
Dim SingleFound ,AtPlace
AtPlace = InStr(1, Name, "'")
If AtPlace > 0 Then
SingleFound = True
LeftStr = Left(Name, InStr(AtPlace, Name, "'") - 1) & "''"
RightStr = Right(Name, Len(Name) - InStr(AtPlace, Name, "'"))
While SingleFound = True
If InStr(AtPlace + 1, Name, "'") > 0 Then
LeftStr = LeftStr & Mid(Name, AtPlace + 1, InStr(AtPlace + 1, Name, "'") - AtPlace - 1) & "''"
RightStr = Right(Name, Len(Name) - InStr(AtPlace + 1, Name, "'"))
AtPlace = InStr(AtPlace + 1, Name, "'")
SingleFound = True
Else
SingleFound = False
End If
Wend
ReplaceName = LeftStr & RightStr
Else
ReplaceName = Name
End If
End Function
%>
<%
set prodconn= server.createobject("adodb.connection")
prodconn.open "Provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("tsl.mdb")
mode=Request.QueryString("mode")
if mode <>"" then
city=Request.Form("city")
end if
if mode="Add" then
flag="Y"
set prodrs=server.createobject("adodb.recordset")
prodquery="select * from cms_reach where reach_name='"&city&"'"
prodrs.Open prodquery,prodconn,3,3
if prodrs.RecordCount > 0 then
flag="N"
end if
prodrs.close
strsql="insert into cms_reach(reach_name"
strsql=strsql&") values "
strsql=strsql&"('"&ReplaceName(city)&"')"
end if
if mode="Modify" then
flag="Y"
city_id=Request.QueryString("city_id")
strsql="update cms_reach set reach_name='"&ReplaceName(city)
strsql=strsql&"' where cat_id="&city_id
end if
if mode="Delete" then
flag="Y"
city_id=Request.QueryString("city_id")
strsql="Delete from cms_reach where cat_id="&city_id
end if
if flag="Y" then
prodconn.Execute strsql
end if
if flag="N" then
Response.Redirect("uploadreach.asp?city="&city)
end if
prodconn.Close
%>