質問

I get the error "No value given for one or more required parameters." at the .Fill

  Dim da As New System.Data.OleDb.OleDbDataAdapter_
        ("SELECT * FROM [" & FileName & _
        "] WHERE Column_Name <> '-1' AND Column_Name <> '-2'", conn)
    da.Fill(dtnew)

This works:

  Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [" _
        & FileName & "]", conn)
    da.Fill(dtnew)

I've added line breaks for clarity.

My two thoughts were:

1) Not possible when using OleBb with a .csv, but I thought I have seen people be successful elsewhere.

2) My formatting is wrong in the query. Nothing I have found on here or Google gives a standard format. Most places I have looked suggest something like []'s around columnname. I have tried brackets all over the place with no luck except new errors.

役に立ちましたか?

解決

Thanks to LarsTech I realized that the column names in the .csv/.xlsx were not the same as the ones in the SQL database. The fix was simple I just had to change the column name to [ID #].

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top