Connection string not found when trying to query database under SubSonic - sql-server-2008

I get this error no matter what version of SubSonic I use. When I query the database for data, it errors out, saying it can not connect to the database.
However, it is able to generate the .cs classes(ActiveRecord, Context, etc) when told to do so.
Any help is appreciated.
Thanks folks...

My guess is that you have your SubSonic generated classes in a separate project from where your main application is (in another project in the same solution). Your main application project references the project containg the SubSonic generated classes.
If this is the case, your main application project must also contain the connection string in a config file, similarly to what your other project has. You might also need to copy over some of the other SubSonic related items from your other project's config file as well.

Related

Magento Triggering Queries

As am Mysql Dba new in Magento FrameWork am unable to find from where the Magento queries are triggering can any tell me the location from where these queries are running
You have not specified which modules data files. Or which query you want to check. Mangento use MVC structure. You will find all data related operations in model. It will be located in app/code/codepool/namespace/module/model
Here code pool will be local or community and third is core but if you want modified file from core copy in local and make changes.
Namespace will be company name and module will be module name.
Hope this will help.

Where should I set the references on a multiple-project solution?

I have two projects on a Visual Studio 2010 solution:
1- A .dll class library called DATA which has a .edmx Entity Framework Model which was created using the wizard and based on the schema of a MYSQL database file.
2- A Windows Forms project which is the User interface and just have the minimum information to sent and receive data to the .dll, which in turn will do the same against the database. This project have a reference to the first one.
The thing is that if I set the connection string on the app.config file of the .dll then when I run my app, it says to me that doesnt find the connection. So I have to set the connection string on the FORM project, which I dont like since Im trying to achieve a minimum of independence from each other.
The same happens with the mysql references... I need to set them on the FORMS project to make the app work... but this is not what I have in plans when I thought of making two separate projects, each one with its own responsibilities.
What I am thinking/doing wrong?

can't create jpa tables in eclipse

I had a working project in eclipse which created a JPA table from entity to mysql database (still learning). Unfortunately it made the table in the wrong database as I wanted there to be 'test' and 'production' databases. Somehow it got the details for the 'production' db, even that it looked like the selected database connection was for the test.
I tampered with the project a bit and made it to connect with right connection object for certain (test). I can ping the db in eclipse (both dbs) and see the db in the Data Source Explorer.
But now I can not create the table(s) for the project by right clicking on it and selecting 'JPA 'Tools' > 'Generate Tables from Entities'.
The creation starts and finishes with no errors, like everything works, yet I see no tables in either of the databases. (In eclipse Database explorer or from command line).
The persistence.xml should be fine as it already created that one table before.
The only error is for the Entity class as it says for the Entity annotation "Table xxx cannot be resolved". And as I see, it's coming from the table not being created.
Here's the persistence.xml just in case.
http://pastebin.com/djPZei90
The project is also a Maven project and it uses SVN. The dependencies were successfully loaded by the maven for the eclipse/project and there is no complications with the SVN.
Because of Maven there are 2 persistence.xml files (only the login credentials and the database name changes), for production and test. It could be that the db-connection was checked and loaded from the wrong file at the 1st place. (just guessing)
Also I tried to create the script.sql when generating the table(s). I found the file but it was completely empty.
Anyway the problem is now that I can't create the tables anywhere.
I am totally puzzled by this. Any hints where I should look to fix this?
Chris had it right, even that I didn't understand the answer correctly at the first reading.
I tried with the other provider, but I may had modified the wrong file by accident (2 'persistence.xml' files as it's a maven project), or there may have been some other reason I failed to spot.
I was given a hint earlier, that I should use the given provider (in persitence.xml). Causing that I didn't pay too much attention to it after all. Since using eclipselink, the provider has to be indeed:
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
Thanks again Chris, even that I failed at the first attempt and had to spend several more hours on resolving this.
Could you solve the problem? Unfortunately I have stumbled on the same rare issue, which totally makes no sense. The JPA Tools just doesn't add the mapping classes for whatever reason, although it writes them into the persistence.xml.
Previous week everything worked flawlessly but now everything is f**. I even created a new independent project in different workspace but it happens the same bug. Obviously it's an eclipse/plugin bug, otherwise I can't explain it. Working with eclipse 4.2.0. I am not happy.
Edit: After removing Dali Tools, JPA Configurator, Seam 3 Plugin creating entities seems to work again. Don't know why, most likely a conflict, but it still doesn't explain why it happened now and not 1 month ago. I didn't change my eclipse install at all since then...
Spend the whole day on this.
I created a completely new (JPA) project in Eclipse (Indigo btw).
Also created a new database (mysql) for that.
Made a connection in Eclipse for that. File > New > Other... > Connection Profile.
Made a new package structure and let the Eclipse create the 'persistence.xml' (src/META-INF/persistence.xml).
I made an 'JPA Entity' class with eclipse wizard. (added 'id' (PK) and 'content' fields)
Copied the 'pom.xml' from my previous project to the new one (made only minor changes like the project name).
Also copied the 'persistence.xml' file from the previous project (src/main/java/META-INF/, no 'test' included). Changed database details and login credentials from the persistence file.
Made the project 'Maven project' in eclipse (right click on project name > Configure)
As it was now a Maven project the default 'persistence.xml' could be removed as it was in wrong place. (Mavenizing the project removed all the errors from un-existing jars with the pom.xml)
Tried to create the table again for the project (Same error, but wait...).
Right clicked on project > Maven > Disable Maven Nature
Then again made it maven project, right clicked on project > Configure > ...
Tried creating the tables again and it created them. Everything works!
Go figure!
Seems like everything was ok, like I suspected. There seems to be some sort of bug with maven (plugin) + eclipse.
Doing the same tricks on the previous project won't help. I even created the entity class with the wizard (removed the existing). The <class> declaration is added to the 'persistence.xml', but it still wont do the table. (Also tried removing and re-adding the maven nature)
I could be missing something on the process/did it differently or doing it wrong whole together. But considering I get the other project work while other doesn't, using the same tricks, there seems to be a big nasty bug.

Entity Code first, where is my DB file stored?

Using Entity 4.1 for a project, and couldn't figure out where the DB file been stored inside my project.
I think I've read that Entity code first will still store your data in SQL Express DB at a default location, but couldn't find out where it is.
What I did is:
create Entity DB project (Project A) in my solution, this project will have an Initializer to generate sample data for testing.
I also create a separate project (Project B) to save my Entity Code first data for testing by another application.
Then I create another WinForm project(Project C) in the same solution, and access DBContext from Project A.
I would assume that the DB should be somewhere in my Project C, and test projects in the solution shouldn't make a difference?
With a default installation of SQL Server Express and no connection string the database will be created in the DATA directory of the installation, for example something like: C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA (for 2008 R2 version). The name of the database is namespace.contextname, for example: MyNamespace.MyContext.mdf (and .ldf). Under this name you can also find them in SQL Server Management Studio.
I know this is an ancient thread covering a different scenario, but google directed me here when I was trying to figure this out for a UWP app, so if anybody follows in my footsteps, here's my solution.
If you're using entity with sqlite in a windows app, your database file will likely be created in the "working directory" of your app. In this case it's:
C:\Users\<Username>\Local\Packages\{Package-Name}\LocalState\
you can find your {Package-Name} by looking in the app manifest. It'll probably be a long string of numbers and letters by default.

Linqtosql sync with the database

I am about to use linqtosql in my first asp.net mvc application.
I have come up with a database schema. But the problem is that I may change few of the tables in future. So keeping the model classes in sync with database will be a issue.
I got this link which states the similar situation,
keep LinqToSQL sync with the database
My question is, has any body used the third party tools given in the above post,
do they work properly
www.huagati.com/dbmltools/
www.perpetuumsoft.com/Product.aspx?lang=en&pid=55&tid=linqtosqlsynchronization
Or is there any better approach for this problem.
The "official" approach is to simply delete any out of date tables from the designer then drag the updated table from your Server Navigator back on again. I've been using this method for well over a year now and so long as you make your data context changes at the same time you're updating the database you should be OK. It also gives you extra incentive to make sure you have your database structure in order before continuing.
There is also SQLMetal.
http://msdn.microsoft.com/en-us/library/bb386987.aspx
This is whats in our CreateDBML.bat file
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
sqlmetal /server:{server-name} /user:{username} /password:{password} /database:{databasename}
/dbml:..\..\Codebase\Domain\CompanyName.ProjectName.Domain\Entities\ProjectName.dbml
/namespace:CompanyName.ProjectName.Domain.Entities /pluralize /views
sqlmetal /code:..\..\Codebase\Domain\CompanyName.ProjectName.Domain\Entities\ProjectName.designer.cs ..\..\Codebase\Domain\CompanyName.ProjectName.Domain\Entities\ProjectName.dbml
pause