Tôi đang cố gắng viết một trang web đơn giản (ASP.NET v4), sẽ gọi Windows Search, tìm một tệp cụ thể và gửi lại cho người dùng. Tôi đã đặt lại với nhau sau đây là một ví dụ: nó gọi là dịch vụ tìm kiếm của Windows trên "RemoteServer", và trả về con đường "somefile.txt":Lỗi mã OLEDB ASP.NET khi được triển khai trên IIS7
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';";
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = string.Format(
"SELECT System.ItemPathDisplay, System.ItemType FROM " +
" sytelhp.systemindex WHERE SCOPE='file://remoteserver/archive' AND CONTAINS(\"System.FileName\", " +
" '\"*{0}*\"')", "somefile.txt");
conn.Open();
OleDbDataReader rdr = cmd.ExecuteReader();
string result=rdr[0].ToString();
.. và làm việc này rất lớn trên Visual Studio 2010 môi trường phát triển, "kết quả" chứa đường dẫn đến tệp. Tuy nhiên, nếu tôi triển khai nó đến máy chủ IIS7 cục bộ (chạy trên Máy chủ 2008), tôi nhận được lỗi này:
The parameter is incorrect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: The parameter is incorrect.
Tôi đang thua lỗ để tiếp theo. Tôi cần phải làm gì với IIS7, hoặc mã, hoặc cả hai để làm cho nó hoạt động? Một lần nữa, điều này hoạt động tốt trong VS2010 (thử nghiệm trên cả Windows 7 và Windows 2008 Server).
*** sytelhp.systemindex *** là gì? – Kiquenet
Đó là tên của máy chủ đang chạy mã. Đây là 6 năm trước :) – KenD