How do I connect to sql server? - c#

I'm trying to connect my database, SQL Server 2012, from Visual Studio 2015 and when I add the data source to the project I always get the error below. Can anyone please help me?

You need to edit your app.config file and modify your startup tag to add this attribute.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>

Related

CrystalReportViewer gives error, "Failed to create component"

When I try to add the crystalreportviewer to my form it gives me this error
Before I decide to post the question I check all the cases and try everything but still the same problem.
Here is the startup in my app.config
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
Your Crystal report version is not match on your visual studio and SDK that is install on your machain

SQL Database constantly resetting after restart

I created a database following exactly this tutorial: https://www.youtube.com/watch?v=OdDkFPO_nto
But when I restart the computer, the tables I created are deleted everytime. I created them in Visual Studio (right click, create new table, type in the columns, click Update, Update OK) and tried to use them (check if the data exists via C#, printing the items of the columns (rows) to the console) and it worked. I closed Visual Studio, opend it again and everything works fine, I can execute the code multiple times without any issues. But when I restart the PC, all tables are gone. I also tried creating the tables in Microsoft SQL Server Management Studio 17, with the same outcome - everything cleared after restart.
How to correctly save the data/the tables?
here is the App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="provider" value="System.Data.SqlClient" />
<add key="connectionString" value="Data Source=ANGELUS-PC;Initial Catalog=tempdb;Integrated Security=True"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
You are creating the tables in the SQL Server temporal (internal) database. It is a system database not intended to users. Create a different database and use it.

Exception with crystal reports

I am developing application which uses SAP Crystal Reports for reporting with Visual Studio 2013 Professional.
I downloaded and install package from SAP site, install that. Report is prepared using wizard (this works correctly). Problem is if I following step in source code:
myCrystalReport.SetDataSource(myDataSet);
myDataSet is filled with required data. Displayed error is:
An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll
Additional information: Could not load file or assembly
'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports
for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI
4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies.
During installation folder dotnet1 were not created. There is only folder dotnet.
Do somebody know how can be this problem resolved?
Thank you.
I had the exact same problem. My solution was to add this xml to the app.config file inside the <configuration> level:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
See also:
CRVS2010- crdb_adoplus.dll not found
Could not load file or assembly crdb_adoplus.dll
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>
</configuration>
Due to mixed mode assemblies has changed this problem will occur so it is recommended to you use above code into app.config file.
you have use below code in app.config and also have to set .net profile 4 client to .net profile 4 or 4.5 in project property.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
All above solution not working in my project and application goes in break mode. i solve this problem by adding following lines in app.config inside the configuration.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>

Crystal Reports are not working in Visual Studio 2010

When i execute crystal report it gives an error
Could not load file or assembly 'crdb_adoplus, Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
Place this code in your app.config
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.2"/>
</startup>
If it would not work then download Crystal Report Runtime from this link http://downloads.businessobjects.com/akdlm/crnetruntime/clickonce/CRRuntime_32bit_13_0_1.msi
If again Crystal Report create some problem then right click on your project, open Properties, open Debug tab and check option Enable Unmanaged code debugging.
If you are running .Net 4 in VS2010, then you may need to add the following to your .config file (configuration section):
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
If this doesn't work, then you need to upgrade to Crystal Report for VS2010 from this link.
Add this code in app config
<startup useLegacyV2RuntimeActivationPolicy="true"> </startup>
If you have visual studio 2010 in your system then crystall report is not install because there is no any crystal report with visual studio 2010.for open the crystal or .rpt file install the sap crystal report 2010.It willl downloaded from sap object websit.

Why did changing my target framework from ".NET Framework 4 Client Profile" to ".NET framework 4" give me warning messages?

The line:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
was added to my App.config file and now i get the warning messages:
Could not find schema information for the element 'supportedRuntime'
Could not find schema information for the attribute 'version'
Could not find schema information for the attribute 'sku'
Can I just delete that line from the config file? Everything works fine when I run the app.
If your application is designed to target the Client Profile, you should setup your app.Config to match. If you want to target the full .NET Framework, make sure to change your project type in the project settings window of Visual Studio to .NET 4 Framework.
There is nothing wrong with this line. From the error messages, it sounds like there is a previous line in your app.config which has errors or is unclosed, or that this line was moved from it's correct place.
This is copied from a working project:
<configuration>
<!-- Other configuration -->
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
These lines are not required. I needed to write a console application to use asp.net membership provider. System.web was not available with client profile. So i changed to .Net framework 4. I removed these lines, it gave me no issues.
Not sure why is it needed at first place.

Categories