I am working on a plugin for the software Autocad in Visual Studio (C#) and would like to import a MS Database manually. I looked a bit online and saw that you can connect to a database via the toolbar but I'd like for the user to import a .accdb file by clicking on a button from WinForms. Is it possible for me to do something like that? I'm thinking of a library or any helpful tool (like System.Xml) so that I can access the database via code and potentially SQL queries.
To make things clearer, here is an example of how the plugin would work:
Every suggestion and tip is appreciated! :)
Use System.Data and System.Data.OleDb.
You'll have to look up your connection string for your database. This isn't a robust solution, but it gets the job done quick.
public DataSet GetDataSet(string sql)
{
DataSet dataSet = new DataSet();
using (OleDbConnection conn = new OleDbConnection(connString))
{
try
{
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(sql, conn);
adapter.Fill(dataSet);
}
catch (Exception ex) { throw new Exception(ex.Message); }
finally { conn.Close(); }
}
return dataSet;
}