astian 0 Newbie Poster

Ok, I think Im missing something Big in programming logic when comes to web applications.
Once again Im clueless about how to proceed in the curent situation. I have a Bing Maps application that connects to a WCF Service to read and write to a database. In this application I have implemented reading from Shape file. Other than the geometry in the shapefile I am also reading the Info for the shapes that is contained in the DBF file. As I believe there is not a way to use database related libraries and operands in silverlight application, I have implemented the reading of the DBF in the Service. The thing is that when I try reading a shape file I get the error: "The ‘VFPOLEDB’ Provider is not registered on the local machine". Here is my code in the Service:

public DBFInfo ReadDBF(int zapis,string filepath, string filename)
        {
            DBFInfo result = new DBFInfo();

            int teku6tzapis = 0;
            string connectionstring = @"Provider=VFPOLEDB.1;Data Source=" + filepath + ";Extended Properties=dBASE III;";
            OleDbConnection connection = new OleDbConnection(connectionstring);
            OleDbCommand command = new OleDbCommand(@"Select * From " + filepath + @"\" + filename, connection);
            connection.Open();

            OleDbDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                if (teku6tzapis == zapis)
                {
                    result.ekatte = reader[3].ToString();
                    result.plost = reader[2].ToString();
                }
                teku6tzapis++;
            }


            connection.Close();
            return result;
        }

As I read in some posts the problem is that I do not have the driver installed. SO, I downloaded it from microsoft: http://www.microsoft...s.aspx?id=14839 , and installed it. Nothing changed... I see that there is a Mentioning of REGISTRATION of the specific driver, but I have absolutely no idea what that means, the instalation or some registration that has nothing to do with the instalation of the driver. I looked in its folder but I have nothing else but two readme files and an icon. I dont know how (if neccessery to register it). ANYWAY the interesting part is that I have written a simple application to test the reading from the DBF files. THe Irony is that I run the exe of that application on the server and opened a dbf file SUCCESSFULY... I have no idea how the reading works when using the simple application and WHY it does not when I call the service.
here is the code of the application - I believe them to be almost identical...(at some extend)

DataTable dt = new DataTable();
            try
            {
                string connectionstring = @"Provider=VFPOLEDB.1;Data Source=" + FileP + ";Extended Properties=dBASE III;";
                //string connectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileP + ";Extended Properties=dBASE IV;User ID=Admin;Password=;";
                OleDbConnection connection = new OleDbConnection(connectionstring);
                OleDbCommand command = new OleDbCommand(@"Select * From " + FileP + @"\" + FileN, connection);

                //string connectionstring = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" + FileP + ";";

                //OdbcConnection connection = new OdbcConnection(connectionstring);
                //OdbcCommand command = new OdbcCommand("Select * From " + FileP + @"\" + FileN, connection);

                connection.Open();

                dt.Load(command.ExecuteReader());
                connection.Close();

                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataSource = dt;
            }
            catch (Exception d)
            {
                MessageBox.Show(d.Message);
            }

So, I would appriciate if someone can tell me why I get this error when trying to read the dbf file in the service. I cant understand why it works fine in the test application and why it doesnt in the service. Some properties and security rights or something concerning the IIS or the service itself or what ... ? Thanks in advance guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.