|
-
Dec 5th, 2000, 05:50 AM
#1
Thread Starter
Lively Member
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
if at first you don't succeed, drink the rest of the bottle and loop to the same place tomorrow
-
Dec 5th, 2000, 10:02 AM
#2
Frenzied Member
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:
Code:
RS.Open "Select * from head_office where ID like '" & searchtext & "%'", Conn, adOpenKeyset, adLockOptimistic
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 5th, 2000, 03:02 PM
#3
Thread Starter
Lively Member
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!
if at first you don't succeed, drink the rest of the bottle and loop to the same place tomorrow
-
Dec 5th, 2000, 04:53 PM
#4
Frenzied Member
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:
Code:
If Err.number <> 0 Then
Response.Write Err.number & " " & Err.Description & "<BR>"
Response.End
End If
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|