Click to See Complete Forum and Search --> : Error accesing to DataBase, where the error is?


angelherriv
January 24th, 2007, 07:14 PM
//Hello folks, I have the following problem to access to a Paradox database, I don't know why,
//all seems to be correct, I have two databases, the first one belongs to MS Access, and the
//second one belongs to Paradox (.db). If I use the first ConnectionString the getDataTable(...)
//method can fill the dataTable object, but if I use the second ConnectionString an error is raised.
//Can somebody helpme, where the error is?,

//Note:

//...both files articulos.db and articulos.mdb are located at "C:\"
//...you can download these database files from:
//http://myfiles.hollosite.com/articulos.zip

//thanks in advance, Angel.


//If you like yo can use a Console Application to test the code
//---beginning-of-code---------

using System;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;

namespace dbTest
{
class Program
{
static void Main(string[] args)
{
string connString;
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\articulos.mdb";

//uncomment the following line to see the runtime error
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Paradox 5.x;";
//Unexpected error from external database driver (11010)

DataTable dt = DataBaseUtilities.getDataTable(connString);
}
}

public class DataBaseUtilities
{
public static DataTable getDataTable(string connString)
{
DataTable dataTable = new DataTable();
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = connString;
string command = "SELECT * FROM articulos";
OleDbDataAdapter adapter = new OleDbDataAdapter(command, connection);
adapter.Fill(dataTable);
return dataTable;
}
}
}

//---end-of-code---------------

wildfrog
January 24th, 2007, 07:18 PM
What 'Data Source' are you using here?
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Paradox 5.x;";
- petter

angelherriv
January 24th, 2007, 07:29 PM
hello wildfrog,
if I use the ConnectionString:

connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\articulos.db;Extended Properties=Paradox 5.x;";

(with the database file included)
I get the error:

'C:\articulos.db' no es una ruta de acceso válida. Asegúrese de que la ruta está escrita correctamente y que está conectado al servidor donde se encuentra el archivo.

what is wrong
regards, Angel.

dcell59
January 24th, 2007, 07:40 PM
I did a quick search on Extended Properties, and it looks like it needs to be:

connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\articulos.db;Extended Properties=\"Paradox 5.x\";";

angelherriv
January 25th, 2007, 04:54 AM
hello dcell59, I tried that but the problem persist, if you have some other idea, please tell me as soon as possible, thanks