by helpnature (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 3rd January 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
'store date from DTPicker control of VB to Oracle database
API Declarations
Dim WithEvents cnPCallocation As ADODB.Connection
Dim WithEvents rsPCallocation As ADODB.Recordset
Dim cmEmployees As ADODB.Command
Set cnPCallocation = New ADODB.Connection
'add more code of connection here
'open the database using recordset object
Set rsPCallocation = New ADODB.Recordset
With rsPCallocation
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockPessimistic
End With
Set cmEmployees = New ADODB.Command
cmEmployees.CommandType = adCmdText
rsPCallocation.Open "select * from <table name>",cnPCallocation
'use to_char function of Oracle to get the date in desired format in query
'set recordset object to datagrid control
Set DataGrid1.DataSource = rsPCallocation
'define the following code in urn SaveData fuction
dim sql as string
'master_pc_allcation is the name of my table in oracle
'dateofallocation is the column name in master_pc_allocation
'pcid is the primay key field in master_pc_allocation
'txtPCID is the name of textbox contrl i used.
sql = "update master_pc_allocation set dateofallocation = to_date('" & Format(DTPicker1.Value, "dd-MMM-yyyy") & "','dd-Mon-yyyy') where pcid=" & txtPCID
'update ur recordset which points to database
rsPCallocation.update
'open the connection of database and execute the sql
cnPCallocation.Execute sql
'requery ur database
rsPCallocation.requery
'datagrid1 is the objectname of datagrid control of VB which shows data
datagrid1.refresh