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!

Adding value to a database!

Status
Not open for further replies.

kruxty

Programmer
Jul 17, 2001
197
PT
When i insert values in a database i need to put the locktype and cursortype?
 
I can't do it without the locktype and cursortype?
If i ommit these what will happen?
 
If you omit them it will default to

Locktype, adLockReadOnly (value = 1)
Cursortype, adOpenForwardOnly (value = 0)

this means the recordset will be ReadOnly (not updateable) and updates by others will not be seen by the RS.

Are you asking how to set the LockType and CursorType or which ones you should use ?



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I put another thread, with one error! But which one should i use? Where can i see all the locktypes available?
 
MSDN

which one to use depends on what you are doing.

Updating (INSERT/UPDATE) will require a LockType of adLockOptimistic (prefered) or adLockPessimistic and a CursorType of adOpenKeyset will be ok.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I'm getting an error of database or objecto is read only when i do the update... i don't understand why! CAn you give me an help?

This is my code:
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 = 1
rsInsereLogins.LockType = 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
 
works fine for me

this
Server.MapPath("dbs\users.mdb")
may need to be this though depending on where the page is that calls the routine.
Server.MapPath("\dbs\users.mdb")

check the file permissions to the database.




Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I had to give permission "full control" to Users on my db. Is that safe? Whish account the system use to open the database? cause i had full controll on my administrator account (the one i'm using now)!
 
It's not the account that you logon with, it's the account that IIS uses. Normally IUSR_computername that needs the permissions granting.

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top