If I understand you correctly...I have this problem whether I use asp or vba. Unless Access already has a record in the table, you cannot insert new ones. My solution has always been to add a bogus record in the table and then all will proceed normally. I have see MS Access (from Microsoft) sample databases do the same thing. I don't know if this is the best solution, but it works.
You should know if the record is new or an old one being edited based on your process flow. If it is new you must send an INSERT statement to Access. If it is being edited then you will send an UPDATE statement.
If for some reason you don't know ahead of time if the record is new or not then you could always query the database for the record. If it is found then run your UPDATE. If it is not found then run your INSERT.
You can not update a record that does not exist. The command will simply be executed and effect 0 records.
You can check how many records were affected by assigning a variable to the second argument of the execute method of a connection object :
<%
Dim lAffected
Dim oCon
Set oCon = Server.CreateObject("ADODB.Connection"
oCon.Execute("Update tblFood Set bYummy = 1 Where idFood = 99", lAffected)
%>
update must work in asp even ur field is empty.if u dont mine please send ur code to me.i think its will be the sql query error.
with regards
webspy(raghuram23@hotmail.com)
I'm sure the record exists, and it doesn't give any problem when the field isn't empty but can just be changed. It does give errors when it is empty (or null). Here is (part of)the code:
dim conn
dim rs
Set Conn = Server.CreateObject("ADODB.Connection"
' conn.close
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Data\products.mdb"
dim ben
ben = replace(request("enbody","'",Chr(17))
if request("enbody" <> rs.fields("enbody" then
set rs2 = conn.execute("UPDATE promotions set enbody = '" & ben & "' where ID_Nieuws = " & request("ID" & ";"
end if
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.