简体   繁体   中英

No value given for one or more required parameters - Excel

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

The error report shows "No value given for one or mor required parameters"

You don't need the parentheses around tablename . Also, does tablename have a valid value? Have you tried stepping through the code to see which line is throwing the error?

I think this query is correctly.

I have caught the same error as yours

At that time , it cannt found the column name (Area)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM