VB6 Update Record with ADO Controller

Ripley

Registered User.
Local time
Today, 11:03
Joined
Aug 4, 2006
Messages
148
Hey guys.

I need to be able to update a record when i click a command button.

I've figured the best way to do this is with the use of an update query.

How would i go about this?

Perhaps set a control such as Dim ADOUpdate As ADODB.Command, set the ActiveConnection to the current connection, the CommandText would clearly be the sql i want to run, and the CommandType is text.

I cant figure out how to do it. Any ideas?:rolleyes:
 
Simple Software Solutions

First make sure you have ADODB referenced in your project

Next
declare the following in your start up Declarations

Public MasterDbConn As New ADODB.Connection


In your Statup Module

MasterDbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyMdb & ";"

MasterDbConn.CursorLocation = adUseClient

Where MyMdb is the path and name of your MDB


To use the mdb in your code use the following

Dim Tbl As New ADODB.Recordset
Set Tbl = New ADODB.Recordset
With Tbl
.Open "YourTableName", MasterDbConn, adOpenKeyset, adLockOptimistic, adCmdTable


Or


Dim rs As New ADODB.Recordset

With MasterDbConn
rs.Open "SELECT * FROM TblLoginSessions WHERE fldUserName ='" & WhoAmi & "'And fldOrganisation ='" & szOrgCode & "' ORDER BY fldLoginKey DESC ", MasterDbConn, adOpenStatic, adLockReadOnly, adCmdText

If Not rs.EOF And Not rs.BOF Then
.....
End If

rs.Close

Set rs = Nothing


The above is snapshots of my code and the table names and critieria is defined by yourself.


Code Master::cool:http://www.icraftlimited.co.uk
 

Users who are viewing this thread

Back
Top Bottom