Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 535 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connection string - Keyword not supported: 'initial catalog'

#1
I am using Webmatrix.data's Database entity to create a database connection, however it doesnt like my connection string. I am running it from MVC ASP.net.

Ive tried changing it to server / database, but still errors the same. Where am I going wrong?

using (var db = Database.OpenConnectionString(@"Data Source=MY-HP\Serv;Initial Catalog=MyDBSQL;User ID=sa;Password=password"))
{
var items = db.Query("SELECT * FROM TaskPriority");
}

**Exception Details: System.ArgumentException: Keyword not supported: 'initial catalog'.**

Reply

#2
check here: [Database.OpenConnectionString Method (String, String)][1]

try to specify the provider name as second parameter, from the MSDN example:

var connectionString = "Data Source=.\\SQLExpress;Initial Catalog=SmallBakery;Integrated Security=True";

var providerName = "System.Data.SqlClient";

var db = Database.OpenConnectionString(connectionString, providerName);

[1]:

[To see links please register here]

Reply

#3
You can use the below code

**Config file :**

<connectionStrings>
<add name="con" connectionString="Data Source=ServerName;Initial Catalog=master;Integrated Security=SSPI;" providerName="System.Data.SqlClient"></add>
</connectionStrings>

**cshtmlfile :**

var db = Database.Open("con");

var selecteddata = db.Query("select * from movie");
Reply

#4
ARRRRHHHHHH!!!!!
*This is the second time I've run into this, grrrh - wasted hours on it.*

Error:

**The server encountered an error processing the request. The exception message is 'Keyword not supported: 'initial catalog;MyDatabase;data source'.'. See server logs for more details. The exception stack trace is:**

Stacktrace:

> at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
> parsetable, String connectionString, Boolean buildChain, Hashtable
> synonyms, Boolean firstKey) at
> System.Data.Common.DbConnectionOptions..ctor(String connectionString,
> Hashtable synonyms, Boolean useOdbcRules) at
> System.Data.SqlClient.SqlConnectionString..ctor(String
> connectionString) at
> System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String
> connectionString, DbConnectionOptions previous) at
> System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey
> key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions&
> userConnectionOptions) at
> System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey
> key) at
> System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
> at System.Data.SqlClient.SqlConnection..ctor(String connectionString,
> SqlCredential credential)

This was my faulty connection string:


`<add name="Production" connectionString="Password=Secret;Persist Security Info=True;User ID=MyUserID;Initial Catalog;MyDatabase;Data Source=aquickborwnfoxjumpedover.us-west-2.rds.amazonaws.com,1433" providerName="System.Data.SqlClient" />`

Looks good right? **WRONG**

Eventually I spotted the semi-colon here:

> Initial Catalog;MyDatabase

To correct it, I used an equal sign:

> Initial Catalog=MyDatabase

The correct connection string:

`<add name="ConnString" connectionString="Password=Secret;Persist Security Info=True;User ID=MyUserID;Initial Catalog=MyDatabase;Data Source=aquickborwnfoxjumpedover.us-west-2.rds.amazonaws.com,1433" providerName="System.Data.SqlClient" />`
Reply

#5
I suggest:


----------


1. You can check your connection string format clearly especialy " and ". In my case this is:

<add name="PolliaEntities" connectionString="metadata=res://*/Models.PolliaEntities.csdl|res://*/Models.PolliaEntities.ssdl|res://*/Models.PolliaEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=MYDB;initial catalog=Pollia;user id=sa;password=asdaskdj;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />


----------
2. You may try generate db by EF again.
Reply

#6
For me I was getting this error because I was using a templated solution. Unbeknownst to me the template only installed support for sqlite. I had to install `Microsoft.EntityFrameworkCore.SqlServer` and change the calls in my code from `UseSqlite` to `UseSqlServer`.
Reply

#7
I ran into the error in one of the IdentityServer quickstarts.

Had to replace

services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));

With

services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));



Using

Microsoft.EntityFrameworkCore.SqlServer

Because obviously my DB was a Microsoft SQL Server and not SQLite.
Reply

#8
You need to check your connection string.

I received the error because I had db(instead of 'Database') in my connection string.

"DevConnection": "server=DEL1-XX-XXXX;db=DonationDb;user=sa;password=XXXX"

Updating the above connection string(**db to Database**) should solve the problem. Below is the working connection string.

"DevConnection":"server=DEL1-XX-XXXX;Database=DonationDb;user=sa;password=QwerXXXX"
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through