"没有给出一个或多个所需参数的值"

时间:2017-06-16 10:32:16

标签: c#

string Category = comboBox1.Text;
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Users\\admin\\Documents\\INV.xlsx; Extended Properties=\"Excel 8.0\"";
OleDbConnection connection = new OleDbConnection(connectionString);
string sql = "SELECT * FROM [RAW DATA$] WHERE [Category: Name] = @Category";
OleDbCommand cmd = new OleDbCommand(sql, connection);
cmd.Parameters.AddWithValue("@num", SqlDbType.Int).Value = Category;
OleDbDataAdapter dataadapter = new OleDbDataAdapter(sql, connection);

1 个答案:

答案 0 :(得分:1)

OleDbCommand不支持命名参数,请查看msdn documentation

像这样更改selectedpics = Hash[uploaded_pics.sort_by { |k,v| -v }[0..availableimages]] selectedpics = uploaded_pics.first(availableimages).to_h selectedpics = Hash[uploaded_pics.to_a[1..availableimages]] selectedpics = uploaded_pics.keys.sort[1..availableimages].each { |key| puts "#{key} #{hash[key]}" } selectedpics = uploaded_pics.first(5)

CommandText