<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cant make connection to acces database in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890290#M21366</link>
    <description>&lt;P&gt;Has nobody a solution for this?&lt;/P&gt;&lt;P&gt;I know Revit can handle acces databases.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 12:02:13 GMT</pubDate>
    <dc:creator>Gilles.Lagrilliere</dc:creator>
    <dc:date>2022-01-19T12:02:13Z</dc:date>
    <item>
      <title>Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10879626#M21365</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't make a connection to an Acces database in Revit.&lt;/P&gt;&lt;P&gt;Every time I use "connection.Open();" Revit crashes without a warning or error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I used to test if I can make a connection to Acces database:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;namespace TestDatabaseConnection
{
    [Transaction(TransactionMode.Manual)]
    public class TestDatabaseConnection : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;

            // Connection string and SQL query       
            string connectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source =" +
                 @"F:\Revit\Families_Codraft\Pipe Fittings\COD_Y-STUK\Test\BMPfittings_PE_riol.mdb";

            string strSQL = "SELECT *" +
                " FROM BMP_TeeTbl" +
                " WHERE (((BMP_TeeTbl.PIPE_OD_M)=110)" +
                " AND ((BMP_TeeTbl.PIPE_OD_R)=110)" +
                " AND ((BMP_TeeTbl.PIPE_OD_B)=110)" +
                " AND ((BMP_TeeTbl.Angle)=45)" +
                " AND ((BMP_TeeTbl.EndType)=\"-;-;-;\")" +
                " AND ((BMP_TeeTbl.THD_ENG1)=0)" +
                " AND ((BMP_TeeTbl.THD_ENG2)=0)" +
                " AND ((BMP_TeeTbl.THD_ENG3)=0))";

            // Create a connection
            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                // Create a command and set its connection    
                OleDbCommand command = new OleDbCommand(strSQL, connection);
                // Open the connection and execute the select command.    
                try
                {
                    // Open connecton    
                    connection.Open();
                    // Execute command    
                    using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            TaskDialog.Show("test", reader["Object"].ToString() + " " + reader["COMP_LEN"].ToString());
                        }
                    }

                    return Result.Succeeded;
                }

                catch (Exception ex)
                {
                    TaskDialog.Show("test",ex.Message);
                    return Result.Failed;
                }
                // The connection is automatically closed becasuse of using block.    
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If I test it with a Console App it works perfectly fine.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 12:12:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10879626#M21365</guid>
      <dc:creator>Gilles.Lagrilliere</dc:creator>
      <dc:date>2022-01-14T12:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890290#M21366</link>
      <description>&lt;P&gt;Has nobody a solution for this?&lt;/P&gt;&lt;P&gt;I know Revit can handle acces databases.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 12:02:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890290#M21366</guid>
      <dc:creator>Gilles.Lagrilliere</dc:creator>
      <dc:date>2022-01-19T12:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890416#M21367</link>
      <description>&lt;P&gt;I tried your code ( with a simpler select statement, and with a simpler file path) and got the same result - an error message that basically said &amp;nbsp;the connection was refused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And a google search seemed to pull up a thread with the same code on another forum, and they seemed to be having the same problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you try running this same code from within another program ( like excel) or as a standalone app and see if you get the same error? &amp;nbsp;That would tell us if it’s a Revit issue or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 12:51:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890416#M21367</guid>
      <dc:creator>stever66</dc:creator>
      <dc:date>2022-01-19T12:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890430#M21368</link>
      <description>&lt;P&gt;If I use a console app it works fine&lt;/P&gt;&lt;P&gt;The console gives me the data I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using System;
using System.Data.OleDb;

namespace ReadingData
{
    class Program
    {
        static void Main(string[] args)
        {
            // Connection string and SQL query       
            string connectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source =" +
                @"F:\Revit\Families_Codraft\Pipe Fittings\COD_Y-STUK\Test\BMPfittings_PE_riol.mdb";

            string strSQL = "SELECT *" +
                " FROM BMP_TeeTbl" +
                " WHERE (((BMP_TeeTbl.PIPE_OD_M)=110)" +
                " AND ((BMP_TeeTbl.PIPE_OD_R)=110)" +
                " AND ((BMP_TeeTbl.PIPE_OD_B)=110)" +
                " AND ((BMP_TeeTbl.Angle)=45)" +
                " AND ((BMP_TeeTbl.EndType)=\"-;-;-;\")" +
                " AND ((BMP_TeeTbl.THD_ENG1)=0)" +
                " AND ((BMP_TeeTbl.THD_ENG2)=0)" +
                " AND ((BMP_TeeTbl.THD_ENG3)=0))";
            // Create a connection
            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {  
                // Create a command and set its connection    
                OleDbCommand command = new OleDbCommand(strSQL, connection);  
                // Open the connection and execute the select command.    
                try 
                {  
                    // Open connecton    
                    connection.Open();  
                    // Execute command    
                    using(OleDbDataReader reader = command.ExecuteReader())
                    {  
                        Console.WriteLine("------------Original data----------------");  
                        while (reader.Read()) 
                        {  
                            Console.WriteLine("{0} {1}", reader["Object"].ToString(), reader["COMP_LEN"].ToString());
                        }  
                    }  
                } 
                
                catch (Exception ex)
                {  
                    Console.WriteLine(ex.Message);
                    Console.ReadKey();
                }  
                // The connection is automatically closed becasuse of using block.    
            }  
            Console.ReadKey();  ;
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 12:58:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/10890430#M21368</guid>
      <dc:creator>Gilles.Lagrilliere</dc:creator>
      <dc:date>2022-01-19T12:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210629#M21369</link>
      <description>&lt;P&gt;I have the same problem with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;string connectionString = @"Driver={Microsoft Access Text Driver (*.txt, *.csv)};" +
&amp;nbsp;$@"Dbq=C:\;" +
&amp;nbsp;@"Extensions=csv,txt;";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works great in a standalone application (WPF APP).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 14:04:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210629#M21369</guid>
      <dc:creator>minet.axel</dc:creator>
      <dc:date>2022-06-02T14:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210648#M21370</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did found a solution.&lt;/P&gt;&lt;P&gt;You need to install Access 2013 runtime.&amp;nbsp;&lt;A href="https://www.microsoft.com/en-us/download/details.aspx?id=39358" target="_blank"&gt;https://www.microsoft.com/en-us/download/details.aspx?id=39358&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 14:06:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210648#M21370</guid>
      <dc:creator>Gilles.Lagrilliere</dc:creator>
      <dc:date>2022-06-02T14:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210844#M21371</link>
      <description>&lt;P&gt;Wow, congratulations on solving and sorry we were not able to help. Thank you for sharing your solution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For future problems: it is almost always helpful to try to fix them manually in the user interface before trying to attack them programmatically. That will often give you more precise error messages and better access to support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 15:28:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210844#M21371</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-06-02T15:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210960#M21372</link>
      <description>&lt;P&gt;But why does it work standalone app without installing Access 2013 runtime? I don't understand why this code doesn't work on Revit.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 16:26:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210960#M21372</guid>
      <dc:creator>minet.axel</dc:creator>
      <dc:date>2022-06-02T16:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210984#M21373</link>
      <description>&lt;P&gt;Maybe:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;An Access library is required&lt;/LI&gt;
&lt;LI&gt;The stand-alone is free to load the one it wants&lt;/LI&gt;
&lt;LI&gt;Revit itself is hard-wired to use the Access 2013 version only, preventing the add-in code to load a different default one&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pure theory, needs testing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 16:37:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11210984#M21373</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-06-02T16:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11211450#M21374</link>
      <description>&lt;P&gt;Ok I understand better now thank you&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 20:48:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11211450#M21374</guid>
      <dc:creator>minet.axel</dc:creator>
      <dc:date>2022-06-02T20:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Cant make connection to acces database</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11359763#M21375</link>
      <description>&lt;P&gt;Wow, thank you... this tread saved my day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was having the same problem as you connecting to an access database, but installing the 2013 runtime solved it.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 14:03:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/cant-make-connection-to-acces-database/m-p/11359763#M21375</guid>
      <dc:creator>moj</dc:creator>
      <dc:date>2022-08-15T14:03:38Z</dc:date>
    </item>
  </channel>
</rss>

