1.txt

来自「VB6.0源码---将图片以数据流保存到数据库。很好的实例参考。」· 文本 代码 · 共 235 行

TXT
235
字号
Public strImgN As String
Public BImg() As Byte



Public Sub LoadImage()
  On Error Resume Next
  Dim ImgS As Long
  Dim OS As Long
  Dim TmpPic As String
  Const conCS = 100
  TmpPic = App.Path & "\tmpPic.bmp"
    If Len(Dir(TmpPic)) > 0 Then
      Kill TmpPic
    End If
      Dim F As Integer
      F = FreeFile
      Open App.Path & "\tmpPic.bmp" For Binary As #F '以二进制文件打开tmpPic.bmp空文件
      ImgS = adomembership.Fields("picblob").ActualSize
      Do While OS < ImgS
        '从数据库中获取图片二进制文件数据块 大小为conCS
        BImg() = adomembership("picblob").GetChunk(conCS)
        Put #F, , BImg
        OS = OS + conCS
      Loop
      '构造mpPic.bmp文件完成
        Close #F
        frmMembership.imgpic.Picture = LoadPicture(App.Path & "\tmpPic.bmp")
        Kill App.Path & "\tmpPic.bmp"
End Sub



'code for image
Public Sub Image()
  On Error Resume Next
  Dim IntNum As Integer
  IntNum = FreeFile
  Open strImgN For Binary As #IntNum
  ReDim BImg(FileLen(strImgN))
  Get #IntNum, , BImg
  Close #1
End Sub


adomembership.Fields("picblob").AppendChunk BImg








































































If False Then
  '先建立空文件=======================================
  Open "c:\test1.txt" For Append Access Write As #1
    Print #1, Text1.Text
  Close #1
  '再读---------------
    Dim tmpStr As String
    Dim tmpVar As Variant
    Dim i As Integer
    Text2.Text = ""
    Open "c:\test1.txt" For Input Access Read As #1
        i = 1
        Do Until EOF(1) '判断是否到了文件末尾:ValBool=EOF(filenumber)
            tmpVar = Input(1, #1)
            tmpStr = tmpStr + tmpVar
            i = i + 1
        Loop
        Text2.Text = tmpStr
        Command2.Caption = "读出" + CStr(LOF(1)) '返回一个文件的大小
    Close #1
  '==========================================
  
  
  '按行读====================================
    Open (Common1.FileName) For Input As #1
    Do While Not EOF(1)
             Line Input #1, Intext
             Text2.Text = Text2.Text & Intext
    Loop
    Close #1
'=============================================

  
  '按行写=====================================
  Dim STR As String
  Open (App.Path & "\Setup.ini") For Output As #1
      Print #1, "[DataBase]"
      STR = "DBName='" & Text1.Text & "'"
      Print #1, STR
      STR = "UserName='" & Text3.Text & "'"
      Print #1, STR
      STR = "UserPwd='" & Text4.Text & "'"
      Print #1, STR
      STR = "ODBCName='" & Text2.Text & "'"
      Print #1, STR
      STR = "DBServer='" & Trim(Text5.Text) & "'"
      Print #1, STR
   Close #1
  '=======================================
  
  '按规律读出
  Open (App.Path & "\Setup.ini") For Input As #1
    Line Input #1, Intext
    Line Input #1, Intext                                       '读入数据库名称
    db_str = MID(Intext, 9, Len(Intext) - 9)
    Line Input #1, Intext
    UserName = MID(Intext, 11, Len(Intext) - 11)                '读入登录用户名信息
    Line Input #1, Intext
    UserPwd = MID(Intext, 10, Len(Intext) - 10)                 '读入用户密码信息
    Line Input #1, Intext
    ODBC_str = MID(Intext, 11, Len(Intext) - 11)                '读入数据源名称
    Text2.Text = ODBC_str
    Close #1
    GetUserName StrName, 255
    Text1.Text = Trim(db_str)
    Text3.Text = Trim(UserName)
    Text4.Text = Trim(UserPwd)
    Text5.Text = Trim(Computer_str)
 '[Database]
'DBName='Data_jdgl'
'UserName='sa'
'UserPwd='232323'
'ODBCName='jdgl'
'DBServer='NIXIUHUI'
 '==========================================================
 
 
 
 
  ' '添加登录系统日志========
    Dim c
       Open (App.Path & "\系统日志.ini") For Input As #1
        Do While Not EOF(1)
             Line Input #1, Intext
             TStr = TStr + Intext + Chr(13) + Chr(10)
        Loop
        Close #1
        TStr = TStr + "   Admin              " + Format(Now, "yyyy-mm-dd hh:mm:ss") + "            " + "登录系统" + Chr(13) + Chr(10)
        Open (App.Path & "\系统日志.ini") For Output As #1
        Print #1, TStr
        Close #1
       TStr = ""
 '======================================================
         StatusBar1.Panels(4).Text = Format(Now, " hh点mm分ss秒")
         
         
End If
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  


⌨️ 快捷键说明

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