williamsba
Programmer
Im having problems with this code. Basically I want to update values in a row where the ID for that row equals the ID I pull from the form. Heres what I have:
Basically it adds the values, but it always adds it to a new row, it doesnt check to find the ID that matches up. I used the WHERE ID = sofu2 (which is the ID from the form) Any ideas on why this isnt working?
Brad Williams
Webmaster
2d Force Service Support Group
United States Marine Corps
Code:
<%
MyDatabase = "../dorn/dorn.mdb"
MyTable = "drinks"
Set MyDataConnection = Server.CreateObject("ADODB.Connection")
Set MyRecordSet = Server.CreateObject("ADODB.Recordset")
MyDataConnection.Open "DBQ=" & Server.Mappath(MyDatabase) & ";Driver={Microsoft Access Driver (*.mdb)};"
if request.form("submit") <> "" then
If request.form("sofu") <> "" then
sofu2 = request.form("sofu")
MySQL2 = "SELECT * FROM drinks WHERE ID = " & sofu2
MyRecordSet.Open MySQL2, MyDataConnection, 1, 3
MyRecordSet.addnew
MyRecordSet("score") = (request.form("rating")) + (MyRecordSet.fields("score").value)
MyRecordSet("votes") = MyRecordSet.fields("votes").value + 1
MyRecordSet.update
Basically it adds the values, but it always adds it to a new row, it doesnt check to find the ID that matches up. I used the WHERE ID = sofu2 (which is the ID from the form) Any ideas on why this isnt working?
Brad Williams
Webmaster
2d Force Service Support Group
United States Marine Corps