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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE DAO RECORDSET 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
411
0
16
IT
attention is a test code!

my code:

Sub TEST()

Dim Rs As DAO.Recordset, db2 As DAO.Database, sConnect As String, SQL As String, queryDef As queryDef
'Set ws = CreateWorkspace("ODBCWorkspace", "", "", dbUseODBC)

sConnect = "Driver={ODBC Driver 17 for SQL Server};Server=99.99.99.99;Database=keystore2;UID=sa;PWD=abcdef;OPTION=3;"
Set db2 = OpenDatabase("", False, False, sConnect)

' Rs.Close
'Set Rs = db2.OpenRecordset("SELECT * FROM CLIENTI", dbOpenDynaset)

'SQL = "UPDATE CLIENTI SET RAG_SOC='PIPPO' WHERE CODICE='100'"

Set Rs = db2.OpenRecordset( _
"UPDATE CLENTI SET RAG_SOC='PIPPO' WHERE CODICE='100'", dbOpenDynaset, _
dbSeeChanges) <<<<<<


'Set Rs = db2.OpenRecordset(SQL, dbOpenDynaset, dbSeeChanges)

'Rs.MoveFirst
'Rs.MoveLast

'Rs.FindFirst "CODICE ='100'"

'Rs.Edit
'Rs("RAG_SOC") = "PIPPO"
'Rs.Update '->>>>>>>> ERRORE !

End Sub

have error in <<<<<<

I need to update the table CLIENTI > fieLd RAG_SOC='PIPPO' where CODICE='100'
 
[tt]"UPDATE CLENTI SET RAG_SOC='PIPPO' WHERE CODICE='100'", dbOpenDynaset, _
dbSeeChanges) <<<<<<[/tt]
 
TKS bro.

But i need to use:

Rs.Edit
Rs("RAG_SOC") = "PIPPO"
Rs.Update '->>>>>>>> ERROR HERE !

original code
Code:
Sub TEST1()

Dim Rs As DAO.Recordset, db2 As DAO.Database, sConnect As String
     'Set ws = CreateWorkspace("ODBCWorkspace", "", "", dbUseODBC)
     
     sConnect = "Driver={ODBC Driver 17 for SQL Server};Server=2.59⁹99.19;Database=keystore2;UID=sa;PWD=Ab8769;OPTION=3;"
     Set db2 = OpenDatabase("", False, False, sConnect)
     '  Rs.Close
     Set Rs = db2.OpenRecordset("SELECT * FROM CLIENTI", dbOpenDynaset, dbSeeChanges)
     
     Rs.MoveFirst
     Rs.MoveLast
     Rs.FindFirst "CODICE ='100'"
     
     Rs.Edit
     Rs("RAG_SOC") = "PIPPO"
     Rs.Update    '->>>>>>>> ERROR !

End Sub

See image
 
For example of:
Update your ODBC driver
 
:) Yes, I did consider that, but decided against, because that just takes you to a set of search results rather than a specific page, and on current evidence I get the impression sal21 would come back to us to ask "which one do I need?"

(also, I suspect it won't fix the issue, but at least means we'll be working with most up to date drivers)
 
sConnect = "PROVIDER = MSDASQL;driver={SQL Server};Server=1.2.3.45;Database=keystore2;UID=sa;PWD=aaaasssss;OPTION=3;"

new driver

 
Be warned - what seems like a public IP address and 'god' level database credentials displayed in an open forum is a very risky thing to do

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
A friend suggest me to set the connection with a dao.workspace.
But i dont know how to!
 
And now let's jkust confirmn - using this new driver (not an uopdate, a completely different one), do you get the same problem?

And, in the meantime, try the following code:

Code:
[COLOR=blue]sConnect = "Driver={ODBC Driver 17 for SQL Server};Server=yourserver;Database=keystore1;UID=userid;PWD=password;" 
 Set db2 = OpenDatabase("", False, False, sConnect)
     
 db2.Execute "UPDATE CLIENTI SET RAG_SOC='PIPPOL' WHERE CODICE='100'"[/color]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top