begin.bas

来自「这个就不用多说了」· BAS 代码 · 共 52 行

BAS
52
字号
Attribute VB_Name = "begin"
 Public P_T As Long
 Public P_l As Long
 Public P_R As Long
 Public P_B As Long
 Public P_Bt As String
 Public P_Bl As Double
 Public P_page As Integer
 Public P_N As String
 Public Zt As String
 Public User As String
 Public JZYEAR As Integer
 Public JZMONTH As Integer
 Public sqlconn As New ADODB.Connection
 Public Data As String '数据库名

 
    Sub Main()
    Dim myclass As New CreateDatabase
       myclass.Create_SysDatabase
       DlForm.Show
    End Sub
Sub sqlconn_open()
 Dim strConntion As String
    On Error GoTo err:
    strConntion = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=" & Data
        If sqlconn.state = 0 Then
          sqlconn.ConnectionString = strConntion
          sqlconn.Open
        End If
           Exit Sub
err:
        MsgBox "不能连接数据", vbInformation, "提示"
        End
    End Sub

 Function AddDataComboBox(ByVal strSql As String, ByVal myComboBox As ComboBox)
 Dim mycommand As New ADODB.Command
 Dim myreder As New ADODB.Recordset
        sqlconn_open
        mycommand.ActiveConnection = sqlconn
        mycommand.CommandType = adCmdText
        mycommand.CommandText = strSql
        Set myreder = mycommand.Execute
        While Not myreder.EOF()
            myComboBox.AddItem (myreder.Fields(0).Value)
                
                myreder.MoveNext
                Wend
                sqlconn.Close
    End Function

⌨️ 快捷键说明

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