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

📄 form2.frm

📁 VB连接SQL实例,对初学者很有帮助,帮助大大滴有
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "Form2"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form2"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   2  '屏幕中心
   Begin VB.Label LblName2 
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   1935
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connstr As String
Private Sub Form_Load()
 connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=db_student;Data Source = mynetserver"
 conn.ConnectionString = connstr
 conn.Open connstr
 rs.CursorLocation = adUseClient
 rs.Open "T_STUDENT", conn, adOpenKeyset, adLockPessimistic
 '给Lable对象的Caption属性赋值
 LblName2.Caption = rs.Fields(1)
 rs.Close
 conn.Close
 Set rs = Nothing
 Set conn = Nothing

End Sub

⌨️ 快捷键说明

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