문제

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