Create .odc file

Discussion created by mkoneya on May 13, 2010
Latest reply on Jun 19, 2010 by mkoneya
I would like to create an .odc file to connect to SQL Server 2005 within a C# project.    I am using the SQL connection to create an XYTheme from a table and would like the .odc connection to be created and discarded after use each time the program runs.

Here is the code that I have so far.    Each time I debug it,   the  'Add OLD DB Connection' form is launched.     I think the problem may be with the Properties that I am using.    I have not found any examples of how to do this, so any help would be appreciated.



private static string CreateODBCconnectionFile(string server,  string user, string password)
            IPropertySet propSet = new PropertySetClass();

            propSet.SetProperty("Provider", "SQL Native Client");
            propSet.SetProperty("Data Source", server);
            propSet.SetProperty("User name", user);
            propSet.SetProperty("Password", password);
            IWorkspaceFactory2 pWSFact = (IWorkspaceFactory2)new OLEDBWorkspaceFactory();

            return pWSFact.Create("d:\\temp\\", "test.odbc", propSet, 0).ToString();