Click to See Complete Forum and Search --> : variables
nutstretch
Dec 5th, 2000, 04:50 AM
I am trying to edit a record in a database. I have used a radio button to select the record i want to edit and the "ID" is kept as a variable. I then go to another form and create a recordset belonging only to the variable record. If I response.write variable it puts the ID number on the form. Why does my line of code below not work.
set RS = Conn.execute("Select * from head_office where ID like '" & searchtext & " ' ")
Also how can i get the recordset when it has found it to go to text boxes ready for altering.
I am reaaly stuck here. Please help
monte96
Dec 5th, 2000, 09:02 AM
If your trying to open a recordset that you can edit, do not use the execute methods of the connection or command object. They ALWAYS return readonly cursors. Instead, try:
RS.Open "Select * from head_office where ID like '" & searchtext & "%'", Conn, adOpenKeyset, adLockOptimistic
nutstretch
Dec 5th, 2000, 02:02 PM
Yes i have set my recordset. Here is my code:
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("PhoneBook.mdb")
set RS = Server.CreateObject("ADODB.Recordset")
rs.open "Select * from Comments where Title like '" & searchtext & " ' ", conn, adOpenKeyset, adLockOptimistic
I don't understand this works on one of my other forms well. Please someone put me out of my misery or put me down!
monte96
Dec 5th, 2000, 03:53 PM
I'm also assuming that you either added the ADODB type library to your global.asa file or included the ADOVBS.INC file on the page. Otherwise, the ADO constants you are using would all be 0.
Also, You appear to have an extra space in your query after the searchtext. If this space is appended to the right side of the searchtext string, it will probably not return any records.
Throw some error checking code after your connection object's open method is called:
If Err.number <> 0 Then
Response.Write Err.number & " " & Err.Description & "<BR>"
Response.End
End If
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.