📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "选择订单号"
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(160, 8)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(192, 23)
Me.ComboBox1.TabIndex = 1
Me.ComboBox1.Text = "ComboBox1"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(184, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(144, 25)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(184, 96)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(144, 25)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(184, 136)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(144, 25)
Me.TextBox3.TabIndex = 4
Me.TextBox3.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(32, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(136, 24)
Me.Label2.TabIndex = 6
Me.Label2.Text = "客户号"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(32, 96)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(144, 32)
Me.Label3.TabIndex = 7
Me.Label3.Text = "雇员号"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(32, 136)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(136, 24)
Me.Label4.TabIndex = 8
Me.Label4.Text = "订单日期"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(136, 200)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(104, 32)
Me.Button1.TabIndex = 9
Me.Button1.Text = "查询"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(8, 18)
Me.ClientSize = New System.Drawing.Size(408, 264)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.Label4, Me.Label3, Me.Label2, Me.TextBox3, Me.TextBox2, Me.TextBox1, Me.ComboBox1, Me.Label1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim con As New ADODB.Connection()
Dim rs As New ADODB.Recordset()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strsql As String
Dim rs As New ADODB.Recordset()
con.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI; Persist Security Info=False;" _
& "Database=Northwind")
rs.Open("select * from orders", con)
Do While Not rs.EOF
ComboBox1.Items.Add(rs("orderid").Value)
rs.MoveNext()
Loop
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmd As New ADODB.Command()
cmd.ActiveConnection = con
cmd.CommandText = "myproc1"
cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
cmd.Parameters.Append(cmd.CreateParameter("@orderid", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput))
cmd.Parameters("@orderid").Value = ComboBox1.Text
Dim rs1 As New ADODB.Recordset()
rs1 = cmd.Execute()
TextBox1.Text = rs1("customerid").Value
TextBox2.Text = rs1("employeeid").Value
TextBox3.Text = rs1("orderdate").Value
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -