数据库名:pic.mdb 数据表名:pics(有两列,第一列为图片ID,第二列为图片的路径名)
问题是:此程序在运行的时候出现错误,原因在哪里???请高手指点.
Dim icount As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oledbcon.ConnectionString = "provider=microsoft.jet.oledb.4.0;data.source=pic.mdb" oledbcon.Open() oledbcmd.Connection = oledbcon oledbcmd.CommandType = CommandType.TableDirect oledbcmd.CommandText = "pics" oledbda.SelectCommand = oledbcmd oledbda.Fill(ds, "pics") icount = 0 Timer1.Interval = 1000 Timer1.Start() End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) icount = (icount + 1) Mod 7 Dim dr As Data.DataRow dr = ds.Tables("pics").Rows(icount) Dim pname As String pname = dr(1) PictureBox1.Image = Image.FromFile(pname) End Sub
Private Sub Form1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Leave oledbcon.Dispose() oledbcmd.Dispose() oledbda.Dispose() End Sub End Class