求助:VB界面启动后,如何自动刷新启动的界面,求代码啊
VB连接SQL数据库,需要实时读取数据库的数据,所以想要通过VB自动刷新界面来实现。Public Sub open_table2() '连接数据库
Dim sql2 As String
connstr = "Provider=SQLOLEDB.1;Persist Security Info=true;User ID =sa;Password=123456;Initial Catalog=PT_AS_DB;Data Source=LENOVO-E298F048"
If conn.State Then conn.Close
conn.ConnectionString = connstr
conn.Open connstr
sql2 = "select * from WarehouseTaskStorage "
rs.CursorLocation = adUseClient
If rs.State Then rs.Close
rs.Open sql2, conn, adOpenKeyset, adLockPessimistic
End Sub
要求:数据库有记录的写入,能够实时加载图片
Public Sub loadpic2() 'A区货架加载图片
If rs.Fields(2) = "HUASOFT_M_00000001" Then Set MSHFlexGrid2.CellPicture = LoadPicture("D:\VB工程\工程2\res\华软.jpg")
If rs.Fields(2) = "1" Then Set MSHFlexGrid2.CellPicture = LoadPicture("D:\VB工程\工程2\res\托盘.jpg")
If rs.Fields(2) = "2" Then Set MSHFlexGrid2.CellPicture = LoadPicture("D:\VB工程\工程2\res\亚克力样件.jpg")
If rs.Fields(2) = "123456" Then Set MSHFlexGrid2.CellPicture = LoadPicture("D:\VB工程\工程2\res\面包.jpg")
End Sub