⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 用vb.net写的基于c/s结构的进销存程序设计源代码
💻 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 rhSQL As System.Windows.Forms.RichTextBox
    Friend WithEvents BnClear As System.Windows.Forms.Button
    Friend WithEvents BnExcute As System.Windows.Forms.Button
    Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
    Friend WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.rhSQL = New System.Windows.Forms.RichTextBox()
        Me.BnClear = New System.Windows.Forms.Button()
        Me.BnExcute = New System.Windows.Forms.Button()
        Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection()
        Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand()
        Me.SuspendLayout()
        '
        'rhSQL
        '
        Me.rhSQL.Location = New System.Drawing.Point(8, 8)
        Me.rhSQL.Name = "rhSQL"
        Me.rhSQL.Size = New System.Drawing.Size(368, 240)
        Me.rhSQL.TabIndex = 0
        Me.rhSQL.Text = "RichTextBox1"
        '
        'BnClear
        '
        Me.BnClear.Location = New System.Drawing.Point(48, 264)
        Me.BnClear.Name = "BnClear"
        Me.BnClear.Size = New System.Drawing.Size(88, 24)
        Me.BnClear.TabIndex = 1
        Me.BnClear.Text = "Clear"
        '
        'BnExcute
        '
        Me.BnExcute.Location = New System.Drawing.Point(280, 264)
        Me.BnExcute.Name = "BnExcute"
        Me.BnExcute.Size = New System.Drawing.Size(88, 24)
        Me.BnExcute.TabIndex = 2
        Me.BnExcute.Text = "Execute"
        '
        'SqlConnection1
        '
        Me.SqlConnection1.ConnectionString = "data source=YEXIAOJIAO;initial catalog=Northwind;persist security info=False;user" & _
        " id=sa;workstation id=YEXIAOJIAO;packet size=4096"
        '
        'SqlCommand1
        '
        Me.SqlCommand1.Connection = Me.SqlConnection1
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(400, 301)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.BnExcute, Me.BnClear, Me.rhSQL})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub BnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BnClear.Click
        rhSQL.Clear()
    End Sub

    Private Sub BnExcute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BnExcute.Click
        '定义变量
        Dim affected As Integer
        '把rhSQL的SQL叙述送到SqlCommand1的CommandText属性
        SqlCommand1.CommandText = rhSQL.Text
        '打开连接
        SqlConnection1.Open()
        '执行SqlCommand1的SQL指令
        affected = SqlCommand1.ExecuteNonQuery()
        '先关闭连接
        SqlConnection1.Close()
        '再秀出总共有多少笔数据被异动的讯息
        MessageBox.Show("共异动:" & Str(affected) & "笔数据!")

    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -