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

📄 frmhwbm.frm

📁 用vb和SQLSERVER编译的关于数据库的源程序例子。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmHwbm 
   Caption         =   "货物资料维护"
   ClientHeight    =   3045
   ClientLeft      =   4830
   ClientTop       =   1815
   ClientWidth     =   6030
   LinkTopic       =   "Form2"
   LockControls    =   -1  'True
   ScaleHeight     =   3045
   ScaleWidth      =   6030
   Begin VB.CommandButton Command 
      Caption         =   "保存(&S)"
      Height          =   345
      Index           =   2
      Left            =   4830
      TabIndex        =   7
      Top             =   120
      Width           =   1125
   End
   Begin VB.Frame Frame 
      Height          =   2745
      Left            =   30
      TabIndex        =   1
      Top             =   90
      Width           =   4695
      Begin VB.TextBox Text 
         Height          =   330
         Index           =   4
         Left            =   1290
         TabIndex        =   11
         Top             =   420
         Width           =   2025
      End
      Begin VB.TextBox Text 
         Height          =   330
         Index           =   3
         Left            =   1290
         TabIndex        =   10
         Top             =   870
         Width           =   2025
      End
      Begin VB.TextBox Text 
         Height          =   330
         Index           =   2
         Left            =   1290
         TabIndex        =   8
         Top             =   2220
         Width           =   2025
      End
      Begin VB.TextBox Text 
         Height          =   330
         Index           =   0
         Left            =   1290
         TabIndex        =   3
         Top             =   1320
         Width           =   2025
      End
      Begin VB.TextBox Text 
         Height          =   330
         Index           =   1
         Left            =   1290
         TabIndex        =   2
         Top             =   1770
         Width           =   3315
      End
      Begin VB.Label Label 
         Caption         =   "原货物编码:"
         Height          =   195
         Index           =   4
         Left            =   180
         TabIndex        =   12
         Top             =   480
         Width           =   1005
      End
      Begin VB.Label Label 
         Caption         =   "货物单价:"
         Height          =   195
         Index           =   3
         Left            =   360
         TabIndex        =   9
         Top             =   2280
         Width           =   825
      End
      Begin VB.Label Label 
         Caption         =   "货物编码:"
         Height          =   195
         Index           =   0
         Left            =   360
         TabIndex        =   6
         Top             =   1380
         Width           =   825
      End
      Begin VB.Label Label 
         Caption         =   "货物名称:"
         Height          =   195
         Index           =   1
         Left            =   360
         TabIndex        =   5
         Top             =   1830
         Width           =   825
      End
      Begin VB.Label Label 
         Caption         =   "货物分类:"
         Height          =   195
         Index           =   2
         Left            =   360
         TabIndex        =   4
         Top             =   930
         Width           =   825
      End
   End
   Begin VB.CommandButton Command 
      Caption         =   "退出(&X)"
      Height          =   345
      Index           =   1
      Left            =   4830
      TabIndex        =   0
      Top             =   540
      Width           =   1125
   End
End
Attribute VB_Name = "frmHwbm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim Conn As ADODB.Connection

Const TxtOldHwBmCode = 4
Const TxtHwBmFlCode = 3
Const TxtHwBmCode = 0
Const TxtHwBmMc = 1
Const TxtHwBmPrice = 2

Const CmdSave = 2
Const CmdExit = 1

Private Sub Command_Click(Index As Integer)
On Error GoTo Errorhandle

   Select Case Index
   Case CmdSave
         SaveRecord
   Case CmdExit
      Unload Me
      
   End Select

Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub SaveRecord()
   Dim ConnStr As String
   Dim Conn As ADODB.Connection
   Dim Cmd As ADODB.Command
On Error GoTo Errorhandle
   
   ConnStr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=;Initial Catalog=fiterp;Data Source=ERP002"

   Set Conn = New ADODB.Connection
   Conn.ConnectionString = ConnStr
   Conn.Open
   
   Set Cmd = New ADODB.Command
   Set Cmd.ActiveConnection = Conn
   

   Cmd.CommandText = "{CALL VBSQLPROUPDATE(?,?,?,?,?)}"
   Cmd(0) = Trim(Text(TxtOldHwBmCode).Text)
   Cmd(1) = Trim(Text(TxtHwBmFlCode).Text)
   Cmd(2) = Trim(Text(TxtHwBmCode).Text)
   Cmd(3) = Trim(Text(TxtHwBmMc).Text)
   Cmd(4) = Val(Text(TxtHwBmPrice).Text)
   
   Conn.BeginTrans
   Cmd.Execute
   Conn.CommitTrans

   Set Cmd = Nothing
   Conn.Close
   Set Conn = Nothing
   
Exit Sub
Errorhandle:
   Conn.RollbackTrans
   Set Cmd = Nothing
   Set Conn = Nothing
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

⌨️ 快捷键说明

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