• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP programming question

Moonark

Senior member
I am writing an ASP application and I am going to use it to add users to a Access database. Does anyone know how to have a search that looks for a duplicate user name in the database. If it finds one it will not update, but if it does not find one it will update. I have been working on this for 2 days now and I cannot seen to figure it out
 
There is a bunch of ways you can handle this. One way is to query the database for the anem that you have. If it finds the name then don't do the update, if it doesn't find it then do the update. It is a simple if statement.

So here is some code for you:

dim sql, rs, update, searchname

searchname = whatever

sql = "select name from tablename where names = '" & searchname & "'"
set rs = conn.execute(sql)

If rs.EOF then
update = true
else
update = false
end if

If update = true then
sql = "INSERT INTO tablename(name) VALUES ('" & searchname & "')
conn.execute(sql)
end if

Oh you have to set your ODBC connection before this set of code. searchname is the name of the user that you are searching for.

Enjoy!
 
Back
Top