Re: vb6 - Edit records
There are 2 ways to UPDATE data in a database table using ADODB against an Open Connection :-
Open a Recordset, Find the Row you want to update, Change the value(s) of the data, Run the Update command against the recordset, Close the Recordset.
Open a "Command" Object, set the Command.Text to your Update Statement, Execute the Command, Close the Command Object.
You are mixing the 2 together.
You need to Identify which Data Row in Table1 needs to be updated with the new "Password" - You are trying to match it against the same Field in the Recordset that you have opened, but you have not moved to a record by using "RS6.MoveFirst" so there is a Null Value in RS6("Password") which is one reason why this is not working. A more logical way would be to match the Row to update against a Username or, better still, the RowID.
Let us assume that you have a User whose name is "John" and it is his password we want to update.
Try this against your Open Connection :-
NOTE that the SQL Statement needs the inserted String Variables valore and strUser to be surrounded by a single quote mark ( ' )
Dim cmd As New ADODB.Command
Dim strSQL As String
Dim strUser As String
strUser = "John"
strSQL = "UPDATE Table1 SET Password='" & valore & _
"' WHERE (UserName = '" & strUser & "')"
cmd.CommandType = adCmdText
cmd.ActiveConnection = Conn6
cmd.CommandText = strSQL
Set cmd = Nothing
[Edited by GeoffS on 13-02-2012 at 04:10 PM GMT]
multi-tasking - the ability to hang more than one app. at the same time.