I am trying to follow a simple example of CLR integration in Sql Server 2008 with C# following:
http://www.sqlservercentral.com/articles/SQL+Server+2008/87743/
But when I try to deploy the project it throws an error:
Beginning deployment of assembly SimpleCLRIntegrationNew.dll to
server xxxxxxxxx\SQLExpress : TableName C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlClr.targets(96,5):
error : Could not connect to server xxxxxxxxxx\SQLExpress BlogData :
Login failed for user 'sa'.
However connection is correct and working
I don't really understand the technical background here, but I noticed the following problem:
When in VisualStudio, check the Project Properties, and under the Database Tab you have the Connection string.
It looks something like this:
Data Source=[ServerName];Initial Catalog=[DBName];Integrated Security=True
I unfortunately didn't copy the connection string from before - but instead of Integrated Security=True it had something with ...User.... I think I had UserID=sa specified, but don't remember exactly, and I don't know why the connection string was set that way.
I clicked the Browse-button and refreshed the connection (chose my DB and clicked 'OK'). The connection string for the project was reset with the Integrated Security=True optionset.
I don't know if it matters, but in my CLR I'm connecting to the db using "context connection=true"
Related
I'm trying to connect my Azure Web App to my AzureSQL database.
In the Kudu Env (https://{my-app-name}.scm.azurewebsites.net/env) there is some kind of default connection string:
LocalSqlServer
- ConnectionString = data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
- ProviderName = System.Data.SqlClient
I have set the connection string in the App configuration, it looks like this:
Data Source=tcp:myapp.database.windows.net,1433;Initial Catalog=databaseName;User ID=databaseSA;Password=password;
But no matter what I try, the connection string in the Kudu environment never changes.
This connection string is also set no where by me, neither in the code base nor in any Azure settings I found.
It's very similar to this SO, which never got resolved: Azure Web App Not Showing Connectionstring in Kudu Env
This is the error message that throws when the app tries to access the database, which makes sense since the connection string tries to connect to .\SQLEXPRESS which doesn't exist anywhere (locally I use .\SQL2019 as connection string):
I would appreciate any help or hint.
So after 3 days I finally managed to get it to work.
First I got it running locally, be sure to white list your IP in the Azure database firewall settings.
Then I got it running in Azure and checking all the names and settings again.
I used the first connection string from my Azure database (SQL Authentication) with the database SA user.
I set that connection string in the connection string of the Azure Web App.
Also make sure that the connection string in your code is the same as the one in the Azure Web app configuration.
Also during some point my App didn't run anymore due to errors in the .Net code, so beware of that.
I thought I had tried this already before posting here, but I guess there were some wrong settings in all these tests.
Im trying to connect to MySQL database on Azure through C#. I am using MySQLConnector package for my program.
I have admin account so I can easily access to the database through Sever Explorer in Visual Studio in SSH Sever Authentication . However I can not do the same with C#. I even tried to copy the exact connection string given by Sever Explorer but I still cant connect to my database through C# . I always get the error "1042: Unable to connect to any of the specified MySQL hosts." . The connection String from Sever Explorer provide necessary param : Data Source, Inital Catalog, Persist Security Info, User ID and Password.
As I have admin account. I have also tried to copy the connection String provided from Azure Portal for ADO.net. The connection String look a bit different . For example it provide extra parameter like
TrustServerCertificate, Encrypt, MultipleActiveResultSets. However if I used this connection string, the program does not compile. Visual Studio tell me the these parameters are not supported . For example :'Option 'MultipleActiveResultSets' not supported.' etc. If I deleted those paratemters, I have the same 1042 error. Please help me, I am new. Thanks
The Connection String from Sever Explorer in Visual Studio look like this:
Data Source= ******.database.windows.net;Initial Catalog=******;Persist Security Info=True;User ID=******;Password=******
The Connection String from Azure Portal look like this:
Server=tcp:******.database.windows.net,1433;Initial Catalog=******;Persist Security Info=False;User ID=******;Password=******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
The Connection String from Azure Portal look like this:
Server=tcp:******.database.windows.net,1433;Initial Catalog=******;Persist Security Info=False;User ID=******;Password=******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
This is a SQL Server connection string. You cannot use MySqlConnector with this connection string. Are you sure you're using Azure Database for MySQL and copying the connection string from the right database?
I've connected to SQL Server in one project by the code below(this would'nt work without #):
private string connectionstring = #"Data source=AHURA-PC\Y;Initial Catalog=contactDB;Integrated Security=true";
However it worked and there is no problem with that but now I want to use Ado.Net Entity Data Model but it can not connect to SQL Server and errors!
Even when I enter Server nameand database then test the connection,it's succeeded but when I press ok it says The system can not find the file specigfied
Then how can I connect to it?
I personally think it's because of that \ after my computer name AHURA-PC.
Is there any way to remove AHURA-PC?
I am a beginner in working with databases. I am trying to access Oracle10g database from a c# application. But when I do so i get this error:
ORA-12154: TNS:could not resolve the connect identifier specified"
I'm using the following code:
string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
Is there an error in the connection string oradb?
Start the Visual Studio, open View menu + Server Explorer.
Right mouse click on Data Connection + Add Connection + Select Oracle Database
server Name : localhost or name of your machine, set username & password and click on Test Connection to verify the above parameters. Press OK if test is succeeds.
From properties windows you can obtain connection String and it should be look a like:
Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True
Oracle is just stating that it can't find the database.
If you're running a local Express Edition database, you should be able to just use XE as an instance name, and everything should already be set up, otherwise you can most easily add it to tnsnames.ora.
To find the correct tnsnames.ora to change, you can try (from the command prompt)
tnsping ORCL
That will tell you which files Oracle is using to try to find the database. If tnsping is an unknown command, you may have to search for it and go to the correct place before running it.
One you found the correct tnsnames.ora, you need to add the instance ORCL to it. There should be an existing file with examples, the syntax of that file is too complex to answer here, if you need help, Oracle has quite extensive documentation.
This is a very common oracle error. Simply put, it means that you have named the database you wish to be connected to and Oracle doesn’t know who the heck you’re talking about. I suggest 6 Steps to fix ORA-12154:
Check instance name has been entered correctly in tnsnames.ora.
There should be no control characters at the end of the instance or database name.
All paranthesis around the TNS entry should be properly terminated
Domain name entry in sqlnet.ora should not be conflicting with full database name.
If problem still persists, try to re-create TNS entry in tnsnames.ora.
At last you may add new entries using the SQL*Net Easy configuration utility.
More informations on oracle site or here : http://turfybot.free.fr/oracle/11g/errors/ORA-12154.html
I am successfully running tests through the the WCF Test Client, until I try to pull in data with Entity Framework.
To make sure I'm not doing anything stupid, I downloaded the sample code from this tutorial, which is doing something similar: http://www.codeproject.com/KB/WCF/WCFandEF.aspx
...and when I run it, I get the same error in a similar place:
var productEntity = (from p in context.ProductEntities
where p.ProductID == id
select p).FirstOrDefault();
The error is
The underlying provider failed on Open.
I can open the database fine from a "normal application" with the same connection string, it seems to be specific accessing the DB from the WCF test client.
Research here and on Google for "The underlying provider failed on Open." usual indicates that it's a connection string problem, but I'm pretty sure it's not in this case.
So now I expect it's some sort of permissions problem.
I am using SQL Server and Windows 7, with visual studio 2010.
I have been banging my head since yesterday, so any help or protective head gear appreciated.
Edited to include connection string
<add name="NorthwindEntities"
connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider
connection string="Data Source=localhost;Initial Catalog=Northwind;User ID=sa;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
This error means 100% a problem in your connection string.
A good way to create a surely working connection string is to create a new(dummy) project, add an Entity Framework Data Model to it, select "Generate Model from Database", select your required connection, and click "Test Conntection" to be sure it works.
Make sure ""Save entity conection settings in App.Config as:..." is ticked.
Than, in you web/app.Config, you have a Connection String you can copy+paste to your own project
Have you tried inserting the database password into the connection string?
It worked for me.
Reference:
http://stack247.wordpress.com/2011/03/02/entity-framework-exception-the-underlying-provider-failed-on-open/
Well I had the same error for days... actualy for two days and Yes I found the solution Alhamdulillah..
As for me... I had Windows Authentication set on my Entity Service Connection.. So What I did was I went to IIS 7 Application Pool Advanced Settings for the web service... Changed the Identity from 'ApplicationPoolIdentity' to 'Network Service' and I setup my current user name and password as well.
I might face some other issues later on, still I would say a Good Start :-)!
I was remove "integrated security=True;" solved this way.