there is a difference, OleDb is position oriented, not name oriented:this.oleDbInsertCommand1.CommandText = "INSERT INTO Authors(firstName, lastName) VALUES (?,?)";oleDbDataAdapter1.InsertCommand.Parameters.Add("@name1","first");
oleDbDataAdapter1.InsertCommand.Parameters.Add("@name2","second");the first ? will get the value "first", the second ? will get the value "second", the name "@name1" and "@name2" are irrelevant

解决方案 »

  1.   

    我在一本书上看到有这么一个例子:const string UpdateQuery = 
        "UPDATE Categories Set Description = @CatDescription" + 
        "WHERE CategoryName = @CatName";SqlCommand cmd = new SqlCommand(UpdateQuery);
    cmd.Parameters.Add("@CatName","Dairy Porducts");
    cmd.Parameters.Add("@CatDescription","Milk");...为什么这个参数加入的顺序就和sql语句中的顺序不同呢?是因为是Sql Server的数据源,不是OleDb的数据源吗?
    如果是这个原因,那么为什么微软不把他们弄成一样的呢?
      

  2.   

    for System.Data.SqlClient, parameters are name oriented, for System.Data.OleDb, parameters are position oriented