I am using the VS2010 + SQL Server CE 3.5 + EF + Framework 4.
I have no problem in reading data from SQL Server CE.
But on inserting data with this code:
EFConn.SaveChanges();
I get an error:
Error: An error occurred while updating the entries. See the inner
exception for details.
please help me...
Error detail :
System.Data.UpdateException was unhandled
Message=An error occurred while updating the entries. See the inner
exception for details.
Source=System.Data.Entity
InnerException: System.Data.EntityCommandCompilationException
Message=An error occurred while preparing the command definition. See the inner exception for details.
Source=System.Data.Entity
InnerException: System.NotSupportedException
Message=Server-generated keys and server-generated values are not supported by SQL Server Compact.
Source=System.Data.SqlServerCe.Entity
SQL CE version 4.0 fixed this problem with its Entity Framework provider.
You can download it from http://www.microsoft.com/en-us/download/details.aspx?id=17876
If you don't want to change SQL CE, you can try to change the field type to uniqueidentifier. You can do this Server-generated keys and server-generated values are not supported by SQL Server Compact
Hope this helps
Related
I have an UWP application with an EFCore 2.1 datalayer which has to get data from a LocalDB, but I'm getting the following error:
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related
or instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify
that the instance name is correct and that SQL Server is configured to
allow remote connections. (provider: SQL Network Interfaces, error: 50
Local Database Runtime error occurred. Unexpected error occurred inside a LocalDB instance API method call. See the Windows Application
event log for error details.
In the Windows Application event log, I have the following errors:
Windows API call CreateMutexW returned error code: 5. Windows system
error message is: Access is denied.
Unexpected error occurred while
trying to access the LocalDB instance registry configuration. See the
Windows Application event log for error details.
Windows API call
FormatMessageW returned error code: 1815. Windows system error message
is: The specified resource language ID cannot be found in the image
file.
Notes:
I can connect to the LocalDB with SSMS.
I have an API in .Net Core 3.1 which is using the exact same datalayer and connection string on the exact same LocalDB, but there's no error on this project and the data are correctly retrieved.
The UWP application can connect correctly to a SQL Server or SQL Express DB with also the same datalayer: only the connection string is changed.
I'm trying to simply switch from SQLite over to Microsoft SQL Server on a basic .NET 5.0 application for local testing purposes.
I'm on Windows 10 running a linux subshell on Visual Studio Code.
I've installed Microsoft SQL Server, and also the SQL Server Configuration Manager as well as SQL Server Management Studio.
I've created a database via SSMS named wmsDB.
And in my Visual Studio Code connection string I have the following:
"ConnectionStrings": {
"DefaultConnection": "Server=DESKTOP-P24QHEM\\SQLEXPRESS;Database=wmsDB;Trusted_Connection=True;MultipleActiveResultSets=true"
}
Every time I run dotnet run and try to sign up via email and password I'm greeted with the below error:
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database 'wmsDB' on server 'DESKTOP-P24QHEM\SQLEXPRESS'.
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'miniwms.Data.ApplicationDbContext'.
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)
I'm not sure what I'm doing wrong - I've tried a few variations of the server name that I was hoping would fix it but still I'm encountering this issue every time.
If you trying to connect from Linux, you'll have to use TCP/IP. By default SQLEXPRESS doesn't have it enabled. Use the SQL Server configuration manager to enable it and set the SQL instance to listen on a fixed port. Use 1433 as it's is the default if you don't have any other SQL Server instances installed.
I am trying to install Umbraco for the first time, and I am using this tutorial. I want to use MySQL instead of MS SQL (which is not shown in the tutorial).
When using the installation wizard, this is the result:
The error logged in UmbracoTraceLog.txt is:
Configured database is reporting as not being available!. Exception: MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException (0x80004005): The requested name is valid, but no data of the requested type was found
MySQL is up and running, and I ended up trying the root user just in case it was a permissions issue. I wounder if the table umbraco-cms should already be filled (what would then be the point of the wizard? and where do I find that info?).
I have searched quite a lot about how to install Umbraco using MySQL but I haven't found the necessary info. Other posts indicate that it shouldn't be that difficult.
I'm using LINQ to SQL (PostgreSQL) via DbLINQ.
I have a problem doing LINQ to PostgreSQL. I succesfully generated .dbml and .cs files with dbmetal and I think I got all the references, the code compiles.
Refs:
DbLinq
DbLinq.PostgreSql
DbLinq.SqlServer
Npgsql
using DbLinq.PostgreSql;
I get an exception:
{"A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: Named
Pipes Provider, error: 40 - Could not open a connection to SQL
Server)"}
inner exception:
{"The system cannot find the path specified"}
connection string:
server=127.0.0.1;database=xxxxx;user id=postgres;password=xxxxx;
ili
server=localhost;database=xxxxx;user id=postgres;password=xxxxx;
If I try to use NpgsqlConnectionStringBuilder I get:
HOST=localhost;PORT=5432;PROTOCOL=3;DATABASE=xxxxx;USER
ID=postgres;PASSWORD=xxxxx;SSL=False;SSLMODE=Disable;TIMEOUT=15;SEARCHPATH=;POOLING=True;CONNECTIONLIFETIME=15;MINPOOLSIZE=1;MAXPOOLSIZE=20;SYNCNOTIFICATION=False;COMMANDTIMEOUT=20;ENLIST=False;PRELOADREADER=False;USEEXTENDEDTYPES=False;INTEGRATED SECURITY=False;COMPATIBLE=2.0.12.0;APPLICATIONNAME=
with an exception {"Keyword not supported: 'host'."}
I connect succesfully over SquirrelSQL and jdbc driver on Win7 64-bit, Postgres 9.2 64-bit
Edit:
this is fine
xxxxxDC dc = new xxxxxDC("server=127.0.0.1;database=xxxxx;user id=postgres;password=xxxxx;DbLinqProvider=PostgreSql;");
var q = from r in dc.xxxxx
select r;
but i get an error on
dataGridView1.DataSource = q
Now i know this is because the query is not executed immediately. But the problem remains. "The server was not found or was not accessible"
F1!
lp
You're showing a series of quite different errors.
The first one is because you haven't told LINQ to use nPgSQL, so it's trying to use MS SQL Server and it cannot connect - since there probably isn't any MS SQL Server on the machine. That's why the error says while establishing a connection to SQL Server.
You then show an nPgSQL connection string from NpgsqlConnectionStringBuilder and the resulting error about the host keyword. As best I can guess, that's because the connection string produced by that class is intended for nPgSQL's own connection handling routines, not for LINQ. You need a LINQ connection string that specifies the PostgreSQL provider.
You then show another connection string you say is "fine" that has DbLinqProvider=PostgreSql; appended to it, but say you get "an error" on a statement after that. You do not show the error message, nor do you show the code you used to set the connection up, so we cannot really help you. It's really a different question to what you originally asked anyway; please post a new question for a new problem, rather than rewriting your original question.
You need a LINQ provider for PostgreSQL. See this question and the wikipedia page on LINQ. Look at dbLinq, LINQ to Entities with a PostgreSQL driver for Entity Framework, or dotConnect.
At time of writing, nPgSQL does not include a LINQ provider so you need to add a 3rd party one. AFAIK you cannot simply use LINQ with nPgSQL directly.
I think postgresql uses a different default port than 1433. Try specifying the port 5432
It worked after I used ConnectionStringBuilder class to make the connectionstring.
Thanks for your help!
FYI, DbLinq project is dead ) In my case it didn't work right away. Your schema may work now, but later you'll likely have to invest your time to update the project )
I am getting the following error while using MySql with Entity framework. I have set the default connection timeout to 300000 on the connection string of EntityConnectionStringBuilder. How to resolve this in Entity framework?
Unhandled Exception: System.Data.EntityCommandExecutionException: An
error occurred while reading from the store provider's data reader. See the
inner exception for details. ---> MySql.Data.MySqlClient.MySqlException: Fatal
error encountered during data read. ---> MySql.Data.MySqlClient.MySqlException:
Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted
to read past the end of the stream.
Update: How can we set net_read_timeout for ado.net entity framework?
Like this
data.Database.ExecuteSqlCommand("set net_write_timeout=99999; set net_read_timeout=99999");
what does the inner exception say?
Unhandled Exception: System.Data.EntityCommandExecutionException does not point to a timeout error, it could be something as simple as an int that needs to be nullable that is used in your EF query.
Could you give the query to?
Cheers