-2

我不断收到参数名称错误?在底部我附上了一张图片来帮助解释这个问题。

private void loadProgress(string jobNumber)
    {

        productioninfo.Open();

        OleDbCommand _contractReview = new OleDbCommand ("SELECT [Contract Review] FROM [Main$] WHERE [Job No] = '@Job No'", productioninfo);
        _contractReview.Parameters.Add("@Job No", OleDbType.Char);
        _contractReview.Parameters["Job No"].Value = jobNumber;

        OleDbDataReader dr = _contractReview.ExecuteReader();

        while (dr.Read())
        {

        }
        dr.Close();

    }

![图片](https://www.dropbox.com/s/54t7xcfhkj7sghu/Parameter%20name.jpg)

4

1 回答 1

1

试试这样;

OleDbCommand _contractReview = new OleDbCommand ("SELECT [Contract Review] FROM [Main$] WHERE [Job No] = @JobNo", productioninfo);
_contractReview.Parameters.Add("@JobNo", OleDbType.Char);
_contractReview.Parameters["JobNo"].Value = jobNumber;

并且不要在表名和列名中使用空格。不推荐。

查看数据库、表和列命名约定?

于 2013-04-24T14:09:02.963 回答