0

I got two problems: First, i'm trying to connect my windows form app with my embedded database (.dbf) and i keep getting this message no matter what i do to the connection string: "error isam instalable cant be found"

Second, i would like to make the path relative to the executable.

Thanks, here is the code i'm using to test the whole thing:

    private void bGuardar_Click(object sender, EventArgs e)
    {
        try
        {
        string cadena = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =D:\\; Extended Properties = dBASE IV; UserID =; Password =;";
        OleDbConnection con = new OleDbConnection();
        con.ConnectionString = cadena;
        con.Open();
        MessageBox.Show("conected");
        con.Close();
        }
        catch (OleDbException exp)
        {
            MessageBox.Show("Error: " + exp.Message); 
        }


    }
3
  • Is your application running in 32-bit, or 64-bit mode? Commented Jul 17, 2016 at 0:41
  • support.microsoft.com/en-us/kb/209805 Commented Jul 17, 2016 at 0:48
  • Well my system is 64-bit but im not sure how to see if my app is running at 32 or 64. And thanks for the link but i allready saw it and it was not clear enough for me, sorry im still learning. Commented Jul 17, 2016 at 0:53

2 Answers 2

1

For the second part, you can get the path of your executable using System.IO.Path.GetDirectory(Application.ExecutablePath). There are more ways do this based upon your need (see Best way to get application folder path).

Sign up to request clarification or add additional context in comments.

1 Comment

string app = Path.GetDirectoryName(Application.ExecutablePath); string cadena = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="+app+"; Extended Properties = dBASE IV; UserID =; Password =;"; I'm trying this now but i does not work also if i use GetDirectory instead of GetDirectoryName it gives me an error. Thanks for the answer tho
0

To avoid further difficulties instead of 'OleDbConnection con = new OleDbConnection();' try

using (OleDbConnection con = new OleDbConnection())
{
    ; // your command and executes here
}

this way you call the dispose / close method always (using generally wraps up your code so that the part between { and } is wrapped in a try / catch block with finally that calls a dispose() / close() on the OleDbConn object.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.