0

I am currently working on a function that connects to a database through a connection string that includes the parameter: "Provider=OleDB.Provider". When I ran the code I get the following error: Unable to format message, ID: 0xc0010001: Class not registered

I have also made sure the file is located on the database and the name parameter I am passing matches the name of the Database, since I got this from the msdn webstie:

"The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created."

Some of the code I have for the connection is(error happens on conn.open):

using (OleDbConnection conn = new OleDbConnection("Provider=mrOleDB.Provider.2;Persist Security Info=False;User ID=\"\";Data Source=" + data_source + ";Location=\"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" + user + "; PWD=" + password + ";Initial Catalog='" + jobnumber + "';Data Source=" + oDatabase + ";OLE DB Services=-4\";Extended Properties=\"\";Initial Catalog=" + oroot + jobnumber + "\\" + jobnumber + ".mdd;Mode=ReadWrite;MR Init MDSC=\"\";MR Init MDSC Access=2;") {
 //(Theres a little more on the connection string but its adding settings for the data collection similar to the last part: MR Init mdsc)
try{
   conn.Open();
}
catch(exception er)
Console.Writelin(er.message)
}

Could you please help me understand this error, or what it means? I tried looking for some solutions but was not able to find a solution that is similar to my issue. Thank you for all your help!

paul590
  • 1,385
  • 1
  • 22
  • 43
  • 2
    Could you provide the full connection string? Are you using Microsoft.ACE.OLEDB.12.0? – Steve Mar 01 '16 at 21:12
  • Hello @Steve Thank you for your help I have updated the connection String. – paul590 Mar 01 '16 at 21:47
  • 1
    Never seen a connection string like that. What database are you using? – Steve Mar 01 '16 at 21:51
  • Its for a database made from a data collection software, I am trying to pull the information from a file it creates. I figured the beginning should be similar, but if its not too familiar do you know what the error means or what should i be looking on the string? – paul590 Mar 01 '16 at 21:58
  • 1
    As far as I know that is not a valid connectionstring. And the error message seems to agree with me. If you are trying to read some kind of Text file then [here you could find some connection string](http://www.connectionstrings.com/textfile/) – Steve Mar 01 '16 at 22:05
  • 1
    See a [previous answer of mine](http://stackoverflow.com/a/35682345/1260204). Look at bullet #3, it walks you through creating `.udl` file which is a great way to build and test a connection string. Once you get it working there copy it from the file to your code and it should work. If you are still stuck then I recommend you read the documentation (if any) that is provided by your `database made from a data collection software` database that you are connecting to. – Igor Mar 01 '16 at 22:07
  • Hello guys thank you so much for your help, I found a solution to my issue! Its a silly thing but my program was running on 32bit, I told MS studio to run on 64 bit and it worked! – paul590 Mar 02 '16 at 21:17

0 Answers0