sql1 = "SELECT distinct(Area) FROM (" + tablename + ")"
Dim ds_area As New DataSet
Dim da_area As New OleDb.OleDbDataAdapter(sql1, MyConnection)
da_area.Fill(ds_area)
Me.ListBox1.DataSource = Nothing
Me.ListBox1.Items.Clear()
Me.ListBox1.DataSource = ds_area.Tables(0)
Me.ListBox1.DisplayMember = "Area"
Me.ListBox1.ValueMember = "Area"
Me.ListBox1.SelectedIndex = 0
Me.cmbArea.Items.Insert(0, "Select All")
For i = 0 To ds_area.Tables(0).Rows.Count() - 1
Me.cmbArea.Items.Add(ds_area.Tables(0).Rows(i)(0).ToString)
Next
Me.cmbArea.SelectedIndex = 0
Catch ex As Exception
MsgBox(ex.Message)
End Try
错误报告显示"没有给出一个或多个必需参数的值#34;
答案 0 :(得分:1)
tablename
周围不需要括号。此外,tablename
是否有有效值?您是否尝试单步执行代码以查看引发错误的行?
答案 1 :(得分:0)
我认为这个查询是正确的。
我发现了与你相同的错误
那时,它找不到列名(Area)