i have problem in asp with vb.

i created a form in asp that is catching data from access database it is working fine but now if i want to modify ( update the data in asp in that same form how to do that.

please it is very urgent if any body know then please help me out.

Thanks in advance..


Hi there,

Use update Query, for update the record/s,

dim rid 'this is the id which will shown in Text Flield of form
Dim Conn 
Dim testconnsrt

'rid = Request.Form("id_") ' use this if you are using form
rid = 1 ' this id which will shown on form

testconnsrt ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/database.mdb") ' connection string

Set testConn = Server.CreateObject("ADODB.Connection")

testConn.Open testconnsrt

str="select * from addBook where id = " & rid
Set rs=testConn.Execute(str)

If Request("Submit") = "Submit" then

userName = Trim(Request.Form("uname"))
useradd = Trim(Request.Form("uadd"))
uid = Trim(Request.Form("uid"))

str="update addBook set username='" & userName & "', useradd='" & useradd & "' where id=" & uid 'SQL Query for update the record

testConn.Execute str

end if

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<form action="update.asp" method="post">
  <table width="50%" border="0" cellspacing="3" cellpadding="2">
      <td><input name="uname" type="text" id="uname" value="<%=rs("username")%>" size="50" /></td>
      <td><input name="uadd" type="text" id="uadd" size="50" value="<%=rs("useradd")%>" /></td>
      <td colspan="2"><input name="uid" type="hidden" value="<%=rs("id")%>" />
        <input type="submit" name="Submit" value="Submit" /></td>

Note : This is only Sample use your fields, table and database names