Nelson,
I was wondering this problem is caused by the OLEDB in your production machine. I wrote some codes to do the Sql statement query using OLEDB directly. Please take a try to see it works:
private DataTable ExcuteSqlUsingOledb(string sqlStatement,string shapeFileName)
{
DataTable dataTable = new DataTable();
dataTable.Locale = CultureInfo.InvariantCulture;
OleDbCommand oleDbCommand = null;
OleDbDataAdapter adapter = null;
try
{
// sqlStatement = ReplaceTableName(sqlStatement);
oleDbCommand = GetOleDbCommand(sqlStatement, shapeFileName);
adapter = new OleDbDataAdapter(oleDbCommand);
adapter.Fill(dataTable);
}
finally
{
if (oleDbCommand != null)
{
oleDbCommand.Dispose();
}
if (adapter != null) adapter.Dispose();
}
return dataTable;
}
private OleDbCommand GetOleDbCommand(string sqlStatement,string shapeFileName)
{
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(shapeFileName) + "\\;Extended Properties=dBASE IV;User ID=Admin;Password=");
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
return new OleDbCommand(sqlStatement, connection);
}
For example, when you want to use the Austinstreets.shp(I did not know your shape file name) as example, try passing following example:
DataTable dataTable = ExcuteSqlUsingOledb("Select * from [AUSTIN~1]", @"C:\PostsData\Austinstreets.shp");
Let me know if any more questions have.
Thanks.
Yale