I'm using Firebird 2.5.0 with the Entity Framework, which has been working well. However, recently I have changed something (I presume) and now the SQL that is being generated when I try to save my changes is not valid for Firebird:
update ( select [fields] from [table]) set [field] = #p0 where ([keyfieldn = #pn])
As far as I know, Firebird 2.5.0 does not support this syntax, and when I try to save changes I get back a SQL error that says as much ( "Token unknown, column 8: (" )
I'm not sure what to do now. What would cause the UpdateTranslator instance to generate this SQL instead of whatever it must have been generating before I broke it?
I went back through the edmx file and found that I had gotten some 'DefiningQuery' elements when I had it pull in some new fields from the database. I couldn't find any way to access those settings in the interface, so I just deleted them from the file and it is working correctly again.
Related
I'm trying to integrate my Oracle Database into my ASP.NET app, but I keep getting this error :
Error 2002: The EntityContainer 'OracleDBTargetContainer' for the
storage model specified as part of this MSL does not exist in
MetadataWorkspace.
I've tried everything I could think of but still can't figure out what's wrong.
What can I do to diagnose the root cause of this?
This is still new to me so I might miss something very obvious.
I'm assuming it my not like my database as the Diagram displayed when I integrated another DB. I've checked the foreign keys, primary keys, ... but to no good.
Using VS2013 with ODP.NET 12c Release 3.
EDIT : My EntityContainerMapping is empty, is that normal?
<EntityContainerMapping CdmEntityContainer="PMModelContainer" StorageEntityContainer="PMModelTargetContainer"></EntityContainerMapping>
I found what was wrong.
One of my foreign key didn't match the primary key (Number 20 instead of Number 10)
I saw on stack overflow that it could be a problem and checked my tables but I missed that one obviously.
How did I realize it ? Well because rather than creating the EF Designer, I chose the Code First from database option, and, oh, what do you know, the error message now tells you EXACTLY what the problem is ! (Table names and columns).
I was using UniDac for a long time now and decided to move on to FireDac as it has good Asynch methods after moving on i saw that none of my data editing works anymore it gives me an error:
[FireDAC][Phys]-330. Cannot generate update query. Update table undefined.
What I am trying to do here is i have a TFDStoredProc component who gets all the data from the database and lets me edit it, with unidac I could easily edit the data without any problem like this:
StoredProc.Edit;
StoredProcCreatedID.Value := SomeValue;
StoredProc.Post;
and it worked, but with AnyDac it doesn't, I tried specifying manually the UpdateTable which leads to another problem:
[FireDAC][Phys][ODBC][Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'CreatedID'.
I am using Microsoft SQL Server 2012 FireDac 8.0 and stored procedures for getting back results any ideas?
P.S.
The query looks like this
SELECT
CreatedBy as CreatedID,
usr.UserName as CreatedBy
FROM
Sales
LEFT JOIN
Users usr ON usr.ID = Sales.CreatedBy
it looks like the FireDac update builder doesn't recognize the aliases on the fields, any help would be appreciated.
Well i figured out what was the issue, it seems that if you specify a alias in the query for a field the Origin property will be set to the alias and not the real field i downloaded CNPack a must have for a delphi developer also its free, ran the component selector and changed all my aliased fields to their real fields and it works, but this is still a big issue in FireDac component because it doesnt recognize the aliased fields, lets hope it will be fixed in the future as to specify for every query what table it should update and what fields that just allot of work if you are migrating from a big project in my case 220+ stored procedures.
I'm trying to get our current database to use FTS. I recompiled the project with FTS3 and FTS4 support on. I know this part works since I've tried some of the examples off of the sqlite pages and they work.
e.g.
CREATE TABLE t2(id INTEGER PRIMARY KEY, a, b, c);
CREATE VIRTUAL TABLE t3 USING fts4(content="t2", a, c);
What I want to do is add a Virtual table to a .db that is already saved to the documents directory of our app. It is writeable.
My question is multi part. First, I tried my query in Firefox's add-on SQLite manager. My query is this:
CREATE VIRTUAL TABLE VirtualTestTable USING fts4(content=Chromosomes, ID Integer Primary Key Autoincrement, rsID, ChrID, Position, Strand, GeneSymbol)
Once I run this in sqlite manager, it creates a few different tables (VirtualTestTable, VirtualTestTable_docsize, VirtualTestTable_segdir, VirtualTestTable_segments, VirtualTestTable_stat).
So I assume sqlite manager supports FTS4. My table is also populated with the data that was original in my Chromosomes Table. But when I try to match anything in the table, I always get zero results. So my first question is, does sqlite manager support FTS queries?
My other question, which is more important to me, is if my query works in sqlite manager, I try this query in my Xcode project with different variations of
content='Chromosomes'
content=\"Chromosomes\"
content=Chromosomes
I always get an error with my query. I'm using FMDB and using the executeUpdate: message. My error is:
Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
Unknown error finalizing or resetting statement (1: unrecognized parameter: content=Chromosomes)
Does anyone know why I'm getting this error? I don't think it's a missing database as when I try to just create an empty Virtual table on my fmdatabase, it runs fine. Thanks.
FTS queries work just fine in SQL Manager:
CREATE VIRTUAL TABLE t USING FTS4(x);
INSERT INTO t VALUES('blah');
INSERT INTO t VALUES('blubb');
SELECT * FROM t WHERE x MATCH 'bl*';
The error message "unrecognized parameter: content=" is typical for SQLite versions that do not support contentless/external content tables, i.e., ones older than 3.7.11.
I want to save the results of the MVC MiniProfiler to a sql server database. I profile a high load mvc4 page to spot a tricky performance problem which is non-reproducible on our test or development system and only happens sporadically on the production server.
What is the best way to hook into the mini profiler? Is there an existing extension to do that?
I've just been setting up MiniProfiler to save the results to SQL Azure, it's fairly easy. We're using MiniProfiler.MVC3 to take care of all the wiring up as described here.
The table create script is embedded into the assembly with the SqlServerStorage.TableCreationScript static field, so you can use that, but while digging into the code I found the latest development branch has enhanced the script slightly by adding some indexes. The table structure is otherwise unchanged, so it still works with the latest package available on nuget.
At the time of writing here is direct link to the latest table create script.
After that the only thing you need to do is set-up MiniProfiler to use SQL with single line of code:
MiniProfiler.Settings.Storage = new SqlServerStorage("<your connection string>");
If you're not using SQL Azure, that's it, but I found one issue when we tried to use it in Azure. I received the following exception (thank you ELMAH) when profiling tried to save:
System.Data.SqlClient.SqlException
Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
To solve this I had to add an additional (unused) column to the MiniProfilers table. Here is the beginning of the create table script in question:
create table MiniProfilers
(
RowId integer not null identity constraint PK_MiniProfilers primary key clustered, -- Need a clustered primary key for SQL azure
Id uniqueidentifier not null,
Name nvarchar(200) not null,
And since the Guid Id column was no longer the primary key, I added an additional index to ensure lookups are still fast:
create unique nonclustered index IX_MiniProfilers_Id on MiniProfilers (Id)
Hope that helps.
Update
The change to support SQL Azure has been provided as a Pull Request and accepted. Thanks Jarrod.
I am importing data from dbase into sql and am using the following connection string to read data:
"Provider=Microsoft.Jet.OLEDB.4.0;" + #"Data Source=D:\GS\Source;"
+ "Extended Properties=dbase 5.0;User ID=Admin;Password=;"
The data is read successfully but i find that it includes DELETED rows too. as per dbase, there will be an asterisk as the first character, however we find that neither the file is excluded nor is the asterisk coming as a column.
So how do we load data without this deleted records?
Actually, deleted records are internally marked with a flag and not an "*" that you can query from. However, VFP does have a function to test this deleted flag, but only really applicable if running from a single table and not multiple/joins as it won't know which table you are wondering out... Ex:
select * from YourTable where not deleted()
That being said, VFP has some other "environment" setting commands that MAY work via the OleDB, but I've never actually tried THIS.
Once you have your connection, and it's open, run the following ExecNonQuery might help...
OleDbCommand oCmdTest = new OleDbCommand( "SET DELETED OFF", YourConnection );
OCmdTest.ExecuteNonQuery();
oCmdTest = new OleDbCommand( "Select * from YourTable", YourConnection );
execute it into a data table result set as you are, and you should be good.
One other part. I would not be using the Jet OleDB, but actually using the Microsoft VFP OleDb driver
In dBase after delete command 'pack all' has to be given so that the deleted records are
removed permanently.
If you have access to dBase use the concerned file and then give pack all command