DataEnviron



Option Explicit

Private Sub Command1_Click()
On Error Goto errorhandler
'To use this routine you MUST have yourcommand _

'as a SQL statement and have a valid statement _

'within it.DataEnvironment1.Commands.Item("Command1").

'CommandText = Text1.Text

'You must manually rebind your datagrid to activate the

'Required commands


With DataGrid1
.DataMember = "Command1"
Set .DataSource = DataEnvironment1
End With

'You must close the recordset between commands

DataEnvironment1.rsCommand1.Close
Exit Sub
errorhandler:
Call errorRoutine
Resume Next
End Sub

Private Sub Command2_Click()

'Valad Tables: Titles, Publishers, Authors, 'Title Author'

'NOTE: you must put single ' around Title Author.


On Error Goto errorhandler
'To use this routine you MUST have yourcommand as a

'DataObject statement and have a valid Object and _

'Object name within it.


DataEnvironment1.Commands.Item(2).CommandText = Text2.Text

'You must manually rebind your datagrid to activate the

'Required commands


With DataGrid1
.DataMember = "Command2"
Set .DataSource = DataEnvironment1
End With
'You must close the recordset between commands

DataEnvironment1.rsCommand2.Close
Exit Sub
errorhandler:
Call errorRoutine
Resume Next
End Sub

Private Sub Command3_Click()
On Error Goto errorhandler
'To use this routine you MUST have yourcommand as a SQL

'statement and have a valid statement within it. Use the ?

'To indicate the Paramater. Make sure your Parameter

'settings are correct.


DataEnvironment1.Command3 Text3.Text
'You must manually rebind your datagrid to activate the

'Required commands

With DataGrid1
.DataMember = "Command3"
Set .DataSource = DataEnvironment1
End With
'You must close the recordset between commands

DataEnvironment1.rsCommand3.Close
Exit Sub
errorhandler:
Call errorRoutine
Resume Next
End Sub

Private Sub errorRoutine()
MsgBox ("You must have appropriate commands In the textbox")
End Sub

Private Sub Command4_Click()
DataReport1.Show
End Sub

Private Sub Form_Load()
MsgBox "Valid Tables: Titles, Publishers, Authors, _
'Title Author'"

'NOTE: you must put single ' around Title Author."

Label1.Caption = " Enter SQL statement"
Text1.Text = "Select * From Titles"
Command1.Caption = "Run SQL statement"
Label2.Caption = "Enter Table Name"
Text2.Text = "Authors"
Command2.Caption = "Run Table Statement"
Label3.Caption = "Enter Year To search Publisher"
Text3.Text = "1985"
Command3.Caption = "Run Paramater Statement"
End Sub

(dataenviron.html)- by Paolo Puglisi - Modifica del 25/3/2019