Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What kind of locktype needed?

Status
Not open for further replies.

kruxty

Programmer
Jul 17, 2001
197
PT
Code:
Sub InsereLogins(User)

Dim adoConInsereLogins
Dim strSQLInsereLogins
Dim rsInsereLogins
Dim Data
Dim Hora

Data = FormatDateTime(Date, 0)
Hora = FormatDateTime(Time, 4)

Set adoConInsereLogins = Server.CreateObject("ADODB.Connection")
adoConInsereLogins.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("dbs\users.mdb")
strSQLInsereLogins = "SELECT Logins.User, Logins.Data, Logins.Hora FROM Logins"

Set rsInsereLogins = Server.CreateObject("ADODB.Recordset")

rsInsereLogins.CursorType=2
rsInsereLogins.CursorType=3
rsInsereLogins.Open strSQLInsereLogins, adoConInsereLogins

rsInsereLogins.AddNew
rsInsereLogins.Fields("User") = User
rsInsereLogins.Fields("Data") = Data
rsInsereLogins.Fields("Hora") = Hora
rsInsereLogins.Update

rsInsereLogins.Close
set rsInsereLogins = Nothing
set adoConInsereLogins = Nothing

End Sub


It gives me this error:

Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
/Procura_Nome/testalogin.asp, line 61

This is line 61:
Code:
rsInsereLogins.AddNew
 
I found the mistake, i had put two cursortypes!

Now says that "Database or object is read-only" in this line:

rsInsereLogins.Update
 
Here is a reference page for the Recordset object: outlines what argumets you can give it for cursor and locktype as well as descriptions.

Though I feel like I should mention that opening a recordset just to add a new record is a bit wasteful, you should simply use a Connection object, the .Execute method, and an SQL INSERT statement.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top