📄 form1.vb
字号:
Imports System.Data.OracleClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Try
'Declare variables and objects
Dim strConnection As String = _
"Data Source=Wrox;" & _
"User ID=thearon;" & _
"Password=thearon;"
Dim objDataSet As New Data.DataSet
Dim objConnection As New OracleConnection(strConnection)
Dim objCommand As New OracleCommand( _
"Chapter12Ex1Package.usp_Chapter12Ex1", objConnection)
objCommand.CommandType = Data.CommandType.StoredProcedure
objCommand.Parameters.Add("results_cursor", OracleType.Cursor)
objCommand.Parameters.Item(0).Direction = _
Data.ParameterDirection.Output
Dim objDataAdapter As New OracleDataAdapter
objDataAdapter.SelectCommand = objCommand
'Fill the DataSet
objDataAdapter.Fill(objDataSet, "Users")
'Bind the DataSet to the DataGridView
DataGridView1.AutoGenerateColumns = False
DataGridView1.DataSource = objDataSet
DataGridView1.DataMember = "Users"
'Set the DataGridView properties
DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = _
Color.WhiteSmoke
'Create and add DataGridView text box columns
Dim objColumn As New DataGridViewTextBoxColumn
With objColumn
.HeaderText = "User Name"
.DataPropertyName = "UserName"
.Width = 200
End With
DataGridView1.Columns.Add(objColumn)
objColumn = New DataGridViewTextBoxColumn
With objColumn
.HeaderText = "Role Name"
.DataPropertyName = "RoleName"
.Width = 100
End With
DataGridView1.Columns.Add(objColumn)
'Clean up
objDataAdapter.Dispose()
objDataAdapter = Nothing
objCommand.Dispose()
objCommand = Nothing
objConnection.Dispose()
objConnection = Nothing
objDataSet.Dispose()
objDataSet = Nothing
Catch OracleExceptionErr As OracleException
MessageBox.Show(OracleExceptionErr.Message)
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -