我正在将一个程序从 Visual Basic 6 更新到 Visual Studio 2010,当然,我发现了很多问题,所以请解决。
我正在使用具有相同键(索引)的四个表的 Access 数据库。
如果我使用如下代码,我可以从 CodDekafix 表中获取最后一条记录:
Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLast.Click
Dim Con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DEKAFIX\Consulta Dekafix\dekafix.mdb")
Dim cmd As New OleDbCommand()
Con.Open()
sql = "Select * From Indice Where CodDekafix=(Select max(CodDekafix) From Indice)"
但是,如果我想从具有相同键(索引)的所有表中获取所有结果,并进行如下所示的更改,则程序不起作用。
sql = "Select * from Indice, dekafix1, dekafix2, dekafix3" _
& " where CodDekafix=(Select max(CodDekafix) From Indice) and" _
& " Indice.CodDekafix = dekafix1.CodDekafix and" _
& " dekafix1.CodDekafix=dekafix2.CodDekafix and" _
& " dekafix2.CodDekafix=dekafix3.CodDekafix and" _
& " ORDER BY Indice.CodDekafix"