Is there a way to change my primary key in Access using ASP?
My primary key looks like this:
1101001CXR001MS 01-01 thru 1101001CXR001MS 01-24
I want to change MS01 to MS04.
My primary key looks like this:
1101001CXR001MS 01-01 thru 1101001CXR001MS 01-24
I want to change MS01 to MS04.
Code:
<% locvar = Request.Form("loc") newlocvar = Request.Form("loc") locCount = 1 locSize = Request.Form("ps") locSize = Cint(locSize) Set MyConn = Server.CreateObject("ADODB.Connection") ' Establish the connection object MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\Paneldata\Databases\FDPIN.mdb;Jet OLEDB:Database Password=niemtel;" Set rsUpdateComments = Server.CreateObject("ADODB.Recordset") 'Getting locbay info for locvar string locBay = Request.Form("bay") locBay = Ucase(locBay) locvar = Request.Form ("loc") & Request.Form("rem") & locBay & "MS" & Request.Form("ms") & "-0" & locCount strSql = "select * from panel where PlantLoc like '" & locvar & "%'" 'Set up a SQL command in a string variable 'Getting newlocbay info for newlocvar string newlocBay = Request.Form("newbay") newlocBay = Ucase(locBay) newlocvar = Request.Form ("loc") & Request.Form("rem") & newlocBay & "MS" & Request.Form("newms") & "-0" & locCount rsUpdateComments.CursorType = 2 rsUpdateComments.LockType = 3 rsUpdateComments.Open strSQL, MyConn 'Update records do until locCount > locSize rsUpdateComments.Fields("PlantLoc")= newlocvar rsUpdateComments.Update 'incrament to next record locCount = (locCount + 1) LocSplit = Split(locvar, "-") LocSplit(1) = CInt(LocSplit(1)) LocSplit(1) = (LocSplit(1) + 1) LocSplit(1) = CStr(LocSplit(1)) if LocSplit(1) < 10 then locvar = Join(LocSplit, "-0") else locvar = Join(LocSplit, "-") end if LocSplit = Split(newlocvar, "-") LocSplit(1) = CInt(LocSplit(1)) LocSplit(1) = (LocSplit(1) + 1) LocSplit(1) = CStr(LocSplit(1)) if LocSplit(1) < 10 then newlocvar = Join(LocSplit, "-0") else newlocvar = Join(LocSplit, "-") end if loop rsUpdateComments.Close Set rsUpdateComments = Nothing MyConn.close ' close the database connection response.write newlocvar response.write locvar %>
Comment