Hi I use the following code to connect to an orace database in Visual Studio 2008 and it is falling over with the exception of ServerVersion threw an invalid operation exception at line 3:
m_strConnectionString = Settings.GetMandatoryConfig("databases", "SourceDB");
m_strQueryTerminator = Settings.GetConfig("databases", "QueryTerminator");
m_odbConn = new OleDbConnection(m_strConnectionString);
m_sql = new SQL(DatabaseType.AnsiSQL, false);
m_strConnectionString is a valid TNS names connection string and is as follows:
Provider=MSDAORA;Data Source=myDS;User
ID=myID;Password=myPW
This has previously worked and is using an IIS web server to host the application. I recently converted it from .Net 1.1 (VS 2003) to .Net 3.5/2 (VS 2008) and can't get it working as yet in VS 2008.
Thanks
Maybe you should consider using the OracleConnection class instead of the generic OleDbConnection. Doing this may give you more specific error information that what you're receiving now - and could help you find your problem quicker.
See here for more information on the System.Data.OracleClient namespace included with the .Net framework.
Related
I get the following exception when I try to connect to my Oracle 9i database from my Visual Studio 2017 application:
ORA-01017: invalid username/password; logon denied
Code:
var connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myServerName)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=mySID)));User Id = myUsername; Password = myPassword";
var con = new OracleConnection(connectionString);
con.Open();
Same problem when :
using same code with System.Data.OracleClient assembly
trying to add a new Data Connection via Server Explorer in Visual Studio.
I tried setting System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy\Enabled to 0 with no luck.
When I use SQL Developer I am able to connect to the same database with same credentials and perform any query.
Any idea ?
Database: Oracle 9i
Visual Studio : 2017
I found the answer.
remove any associated plugin in Visual Studio
execute uninstall.bat from your ODAC downloaded folder
remove any associated tool in Windows Add or Remove Program
Remove remaining Oracle folders (in C:\, C:\ProgramFiles, ...)
Make sure there is no remaining Oracle reference in GAC, otherwise delete them.
The latest compatible version of Oracle provider is Oracle version + 2 (9+2=11), meaning the maximum version I had to install was 11.2.0.4. After installing this version and compile my code in x64 (Any CPU or x32 won't load the DLL) evrything was working.
How can I repair SQLServerCE Database from C# code.
I am using this call:
engine.Repair(GetDBConnectionString(), RepairOption.RecoverAllOrFail);
where GetDBConnectionString() is a private function that builds Connection String for me.
But this raises exception:
"The file that is being referenced is not a SQL Server Compact database file format"
Regards,
Pawel
You are using the wrong ADO.NET version in your own app. I think you may get this error if you use version 3.5.1 against a 4.0 database
I've kicked my head with this one for several days now. I've done a lot of research and have found issues closely related but not specific to my case.
Working on a Visual Studio 2008 SSIS package. Using only one scripting component. In this scripting component, I am serializing a stongly typed class (CCMSModel) and trying to write it out to the server's d:\ drive. I am using .NET 3.5. Works just fine on my development machine but breaks when I deploy it to my SQL Server 2008 R2 (SSIS). I've completely trimmed down my code to remove any added complexity:
[Serializable]
public class CCMSModel
{
public string BOBorEOB { get; set; }
}
...
List<CCMSModel> myList = new List<CCMSModel>();
CCMSModel item = new CCMSModel();
item.BOBorEOB = "Test";
myList.Add(item);
string filePath = "d:\\ScheduleFiles\\6xml\\ss.xml";
var serializer = new XmlSerializer(typeof(List<CCMSModel>));
using (var stream = File.OpenWrite(filePath))
{
serializer.Serialize(stream, myList);
}
...
Want to add that I have sufficient rights to write on the server and I am a sysadmin on the sql server. I also have an another SSIS package using Visual Studio 2012 (SSIS) with .NET 4.0 and deploying to SQL Server 2012. This package is EXACTLY the same (did a copy / paste of the code) and it works just fine.
In my research I found an article that I couldn't help but to see a very close relationship to. Same error and same code. However, this particular scenario is using .NET 4.0 and is deploying or executing in an environment that has .NET 4.0 and 4.5. The article contains a link (at the bottom) claiming to solve the problem (specific to the 4.0/4.5 framework). Claims that the XMLSerialize, in 4.5, is a bit different from the one that runs on my C# compiler hence the incompatibility.
InvalidProgramException with XmlSerializer
Although the article present a close resemblance, this isn't specifically my set up (since I am on 3.5). However, it does allude to the fact that I may be experiencing some incompatiblity with the XMLSerialise implementation. I've hunted down to see if this was the case but I've run dry on my search.
I get an this inner exception error:
System.TypeInitializationException: The type initializer for 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterList1' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterList1..cctor()
I am trying to open a connection to a Firebird database in my c# asp.net web application. It throws an error "The type initializer for 'FirebirdSql.Data.Common.TimeoutHelper' threw an exception."
I am new to Firebird.
In web.config I have:
<add name="FireBirdConnectionString" connectionString="Server=localhost;User=SYSDBA;Password=masterkey;Charser=NONE;Database=D:\data\SAMPLE.fdb" providerName="FirebirdSql.Data.FirebirdClient"/>
I have installed FirebirdSql.Data.FirebirdClient-4.5.1.0 and have added a namespace of
using FirebirdSql.Data.FirebirdClient;
I am opening the connection like below:
using (FbConnection con = new FbConnection(conString))
{
con.Open();
}
But this shows me an error as The type initializer for 'FirebirdSql.Data.Common.TimeoutHelper
What am I doing wrong?
I need to open the connection.
Even in connection string
and I have that path in my desktop too
Thank You..!
As I commented earlier, you are probably using the .NET 4.5 version in a .NET 4 project. You either need to switch your project to .NET 4.5 (which requires Visual Studio 2012 or 2013), or you need to replace the FirebirdSql.Data.FirebirdClient library with the .NET 4 version.
I'd suggest you use NuGet to install it, as this will verify - install time - which variant you need. Otherwise you need to pick the second link from http://www.firebirdsql.org/en/additional-downloads/ (iirc the first link only installs and includes the .NET 4.5 version).
I am relatively new to Visual Studio and I figured the best way to proceed would be to [sarcasm] do a major project [\sarcasm].
Summary of work to be done here:
VS2008 -> VS2012
Windows7 -> Windows8
SQL CompactServer v3.5 -> SQL CompactServer v4.0
.NET Framework v2.0 -> .NET Framework v4.0
One of the problems I am running into is that even though I have migrated my DB file in VS from SQL_CE_v3.5 to SQL_CE_v4.0 and updated my references to System.Data.SqlServerCe (4.0), I am getting the following exception when an attempt to open the db file is made the following way.
DB.DataContext = new DB.DataContext(CONNECTION_STRING);
Exception:
System.InvalidOperationException: Cannot open '|DataDirectory|\Database.sdf'. Provider 'System.Data.SqlServerCe.3.5' not installed.
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Initialize(IDataServices dataServices, Object connection)
at System.Data.Linq.DataContext.Init(Object connection, MappingSource mapping)
at System.Data.Linq.DataContext..ctor(String fileOrServerOrConnection, MappingSource mapping)
.
.
.<br>
Question:
How can I change the provider name here to 4.0 instead of 3.5?
What would be the best way to do all these migrations?
Initialze the DataContext object with a SqlCeConnection object, not a connection string, so something like:
DB.DataContext = new DB.DataContext(new SqlCeConnection(CONNECTION_STRING));