Connection String - asp.net

I have a asp.net application.there is a databinding section to a datagrid.But there have an error.I think it may be in web config-Connection string.
Connection String is like this
<add name="ArchitectConnectionString" connectionString="Data Source=192.168.1.15,1433;Network Library=DBMSSOCN;Initial Catalog=Architect;" providerName="System.Data.SqlClient" />
the error is
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
Please help me..

You need to specify a username/password to the end of the connection string,
";User ID=UserName;Password=Password"
Or if you are using Windows Auth then
"Integrated Security=True"

The connection string is expecting a user id and password add the following string to the end of the connection string:
String to add:
Userid=myUserID;Password=!12345
Complete altered string example:

Related

Database connection not working in ASP MVC

I just create a new ASP MVC sample. The code was generate with scaffolding. Then I run the application and it runs smooth. But when I click "Register" link in top nav bar and tries to register it does not work.
My Connection String:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-ProductExa‌​mple-20151218101004.mdf;Initial Catalog=aspnet-ProductExample-20151218101004;Integrated Security=True" providerName="System.Data.SqlClient" />
It is saying that your connection with sql server is not established.
Please check your connection string.
Here i am showing mine. Please check it once. It may help you.
<connectionStrings>
<add name="DemoEntities" connectionString="metadata=res://*/Models.Report.DemoEntities.csdl|res://*/Models.Report.DemoEntities.ssdl|res://*/Models.Report.DemoEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=192.168.1.2\SQLEXPRESS;initial catalog=DEMODB;user id=abc;password=abc;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Check all following parameters are correct or not.
data source=192.168.1.2\SQLEXPRESS;
initial catalog=DEMODB;
user id=abc;
password=abc;
According to your sql server configuration you need to correct your connection string.
I needed to write IP\InstaceName may be in your you only need to write IP or only instace name. Please check it once.
check sql server express is install or not on your machine if not then use local sql server that is install on your machine and change connection string
data source=.;
initial catalog=DEMODB;
user id=abc;
password=123;

How to specify Oracle SID to connectionStrings in web.config?

I have an ASP.NET application whose connection to the database seems to fail to open because of the Oracle SID not being specified. I can't find any doc on how to specify it in the connection string. Did anyone have the same problem?
Here is the sample :
<connectionStrings>
<add name="{ConnectionName}"
connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;"
providerName="Oracle.DataAccess.Client"/>
</connectionStrings>
After adding the connection string to the web config you can use
System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString;
To retrieve the connection string

connectionstring to sqlmembershipprovider asp.net

I have added the sqlmembershipprovider to my dynamic data project for logging in and registering and such.
However, I am having problems with the connection string. The database is on a remote sql server 2008 database server.
Below I have a connection string for the entities:
<add name="xxEntities"
connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string="Data Source=xx.xx.x.xxx;Initial Catalog=XX;Integrated Security=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
When I hit the membership provider, I get this error:
Keyword not supported: 'metadata'.
on this line of code:
System.Web.Security.Membership.GetAllUsers(0, 1, count)
Do I need a separate connection string for the provider? Or should I be able to use the above string with all my connections, including my membership provider?
thanks.
Try using this connectionString template + change the User-ID, Password, Initial Catalog
Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=xxx.xxx.xxx.xxx;User ID=RemoteApp;Password=xxx;Initial Catalog=xxx;

ASP.NET A problem when connect from remote DB to localhost instance

I have made the remote database backup (MSSQL Server 2005 Express) to the localhost, and I want to connect with that in my app. To do so, I've changed the connection string:
from
Data Source=190.190.200.100;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
to
Data Source=TOMEK\SQLExpress;Database=myDataBase;User ID=myUsername;Password=myPassword;
but the error appears: Format of the initialization
string does not conform to specification starting at index 0
I can login to the Management studio with that login/pass, and also the user name that I login into sql server has role membership db_owner to that database
what's wrong with that connection string ?
Try one of the 2 options.
Data Source=foo\SQLExpress;Initial Catalog=bar;User Id=user;Password=pwd;
or
Server=foo\SQLExpress;Database=bar;User ID=user;Password=pwd;
They're equivalent, but not sure if you can mix/match
Server/Data Source
Database/Initial Catalog
Are you using a hardcoded string, or from a .config file? Does your username or pwd contain any characters that might need escaping in the .config file? i.e. slash, ampersand?
string connstr = #"Server=foo\SQLExpress;Database=bar;User ID=user;Password=pwd;";
SqlConnection conn = new SqlConnection(connstr);
<add name="ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;Database=bar;User ID=user1;Password=&foo;"
providerName="System.Data.SqlClient" />
Maybe try comparing what you are doing to what is found here:
http://www.connectionstrings.com/sql-server-2005

What is wrong with this connection string?

Hai guys,
I use the following connection string
<add name="connectionString" connectionString="server=localhost;user id=root; password=; database=lms; pooling=false;" providerName="MySql.Data.MySqlClient"/>
It gives me the error There is no 'lms'#'%' registered.
My database server is localhost and the user account doesn't have a password..
Here's a working connection string for MySql:
server=localhost;user id=root;password=xxx;database=xxx;pooling=false
Can you connect from the command line (using "mysql")?
Is mysql by any chance bound to a different IP other than localhost (in my.ini)?
If you don't have a password, have you tried leaving off password=?
If that doesn't work, you may have to add a password....
F0r MySql, should be something like:
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword
Shouldn't it be something like:
<add name="ConnString" connectionString="Database=lmz;Data Source=localhost;User Id=root;Password=;CHARSET=utf8;" providerName="MySql.Data.MySqlClient"/>
Also check that the user has permissions to the database.

Resources