vb 数据库 自动生成文件

来源:百度知道 编辑:UC知道 时间:2024/05/14 19:29:21
我现在用vb做化学分析仪的上位机,每次做完分析都会要求把得到的数据存储到ACCESS文件"数据库.mdb"中的表"结果库"中.现在要求我实现一个功能,就是按月自动生成另一个以日期命名数据库文件,里面的数据是"数据.mdb"中的表"结果库"在这一个月的记录.之后把这个文件自动发送到局域网上.
不知哪位高手会,请一定帮忙.会其中一部分也行.给点灵感.多谢了

小写字母的ascii值在90到116 之间
用rnd随机函数获得这之间的值,在使用chr或者其他函数转换成字符类型,

dim filename as string
filename="D:\VB\123"+chr(rnd()*90+26)+chr(rnd()*90+26)+chr(rnd()*90+26)+".txt"

没有测试过,思路应该是对的

'SQL版

Private Con As String = "<连接字符串>"'<连接字符串>可以自动生成
Private connection As SqlClient.SqlConnection
Private command As SqlClient.SqlCommand
Public Function DBopen() As Boolean '打开数据库
Try
connection = New SqlClient.SqlConnection
connection.ConnectionString = Con
connection.Open()
Return True
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
End Function
Public Function DBclose() As Boolean '关闭数据库
Try
connection = New SqlClient.SqlConnection
connection.ConnectionString = Con
connection.Close()
Return True
Catch ex As Exception
MsgBox(ex.ToString)
R