Sql iphone error no such table - iphone

I have a problem with sql lite in my app. I cause an error "No such table" when try to insert data in table. I create database file on documents directory and after i create a table (this table creates without errors in my program but doesnt create in database). Please help me out.

Firstly check the database path, then go to database path. Check it.
Delete the data base from your project, and simulate and build.
Again drag database.
Run your project and check database.

Related

Can you restore a table in mysql workbench?

I dropped a mysql table and don't believe I explicitly enabled any sort of backups is there a way to undo the drop statement?
Once a table is dropped, it is gone. Without a backup you won't get it back. So, no there's no way to undo the drop statement.
Closest I got was to partially restore the structure (with no data) by retracing the create/alter statements. I went to help > locate log files and analyzed the log file for a given DB.
P.S: Problem is that for reasons unknown when you alter the table via "alter" button in workbench it doesn't register the queries in log files, it just says "Altered changes" or something which is pretty dumb, otherwise the whole structure would have been restored...

Use EDMX file to generate a database?

I have lost my SQL script to generate tables for my database, good thing its not for a client. I thought I had a backup but I do not.
I do have an EDMX file in my project though, so is there any way that I can create the database schema off of the EDMX?
Right click the EMDX design surface, you will find a generate database option there to give you your sql scripts or directly populate a database.

Delete database. Entity Framework

I followed the following MDSN tutorial:
http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-model
Then I tried this guide according to my needs and I set up a database GAMES.MDF.
Then, I deleted the database and set it up again, is supposedly work (I can write and read data), but there is no such database in the APP_DATA folder. It seems to exist, but somewhere else on my PC.
 
I even tried a new project and it did not work, works but not in the library, and it even uses the data I created before. I even deleted the DB from SQL Server Management Studio 2008.
How do I delete it permanently, not to remain any trace of it?
Check for the connection string in the web.config - You'll probably see the file location there.
Your connection string should ideally name the database you want to use. I would not recommend specifying the MDF file, unless you know you are using SQL Express. Source: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f21c0728-935d-492a-baaf-ff2704e3683b/attachdbfilename-option-in-connection-string?forum=sqldataaccess0
Instead, this is how it is done on SQL Server:
initial catalog=MyDatabase
To be sure you are accessing the database you think you are, run this SQL query through your app, using your connection string, and look at the physical file location of your MDF file. This query is handy for knowing which DB is tied to which DB files.
select * from [dbo].[database_files]
As far as actually clearing the DB, this article deals with managing database initializers and seeds. You might be experiencing a problem due to that:
How to delete and recreate from scratch an existing EF Code first database
Outside of EF, SQL deletes databases like this:
use master
drop database MyDatabase

Alter database to match model

Originally, I used Data Modelling in MySQL Workbench to design a database consisting of a series of tables (i.e. the columns and relationships).
Then using Database -> Forward Engineer, I created a database, and inserted data into the tables.
Now I've realised that the model I've designed needs some changes, and so I've altered some tables by inserted columns. My question is, how do I get MySQL Workbench to alter the tables?
Using Database -> Synchronize Model, Update Source just generates a bunch of CREATE TABLE IF NOT EXISTS sql statements, and as the tables exist, nothing changes.
What you are looking for is in the model menu Database / Synchronize model.
As I couldn't get get File -> Export -> Forward Engineer SQL ALTER Script to work, so I made a backup of the data, dropped the tables, recreated them, and then imported the data. I'd rather find a way to get MySQL Workbench to generate ALTER commands from the changes in my model
The 2011 answer is no longer up to date. I struggled to find the option in a recent version. Here is the new procedure (works for MySQLWorkbench 6.2 at least):
When you have finished editing your model, open Database -> Synchronize with Any Source
In the step Select Source you have 3 parts
Source : choose Model Schemadata
Destination : choose Live Database Server
Send updates to : choose whether the live database should be updated or if you only want to saves the changes to a .sql file
Proceed in the wizard, you can then review the tables and sql queries that will be executed. You can also ignore the update of some tables.

core data with pre populated sqlite from csv!

Ive been struggling with this for a couple of days now and after scouring the internet I still havent got it working. I have a csv file, from which I need to populate an sqlite db to use with core data.
I thought I had found a solution here http://ablogontech.wordpress.com/2009/07/13/using-a-pre-populated-sqlite-database-with-core-data-on-iphone-os-3-0/ but I cannot for the life of me get it to work. Here are the steps I have taken.
Created a new Core Data project and generated the model and Managed Object classes;
Performed a fetch request in vdl of rootViewController (Im not sure why this is neccessary but apparantly it is?)
Copied the xxx.sqlite from the documents directory of my app into another directory.
Executed the following sqlite commands from the terminal:
sqlite3 xxx
sqlite> .mode csv yyy
sqlite> .import yyy.csv yyy
Now when it comes to importing the csv data into my table I get a no such table error! Also when i execute a .tables command I get Z before my table name?
I have imported data from a csv into a table this way before but not using a core data generated db and I think this is where the problem lies. Does anyone know where Im going wrong or of a better solution to my problem. Please let me know as Im going crazy with this..
Many thanks
Jules
Take a look at this post
What you want to do is set up your core data stack then import each record and insert new managed objects and use the values from the csv to set your object's properties.