Wrote a Truck show Contest voting app, financial etc using sqlite. decided to write backup app for show day using ce 3.5. Created db moved to data directory, created tables configured dgridviews all is well. Entered some test data started management studio 08 ran select query against table and got null returns. Started app from vs studio and found that test data is gone. Re entered data ran query in MS data gone again.
If I use VS Studio can start and enter data, close app restart and data is still there, seems only when using outside tool on select query data deletes.
I don't know CE that well but this cannot be right.
select * from votes = delete * from votes??????????????
You're probably overwriting the database during your build.
Related
I have created a database with several tables, and I also created a C# Windows forms application. Occasionally, after testing the application, I will find tables empty that were filled using the application (and stayed full upon several further testing - data can also be seen on vs server explorer => show table data).
Not only are tables empty but the only data that I do access when this occurs is data that I have entered from a long time ago and I have deleted (while I was testing deleting from my tables).
I have put using{ ... } around all my code that connects to databases, It is a one off event , if I run the code, edit some of table data in the application, the database will change, then if I will run again and the data will be updated from the last run, several times later - randomly the data will go missing...
My connection string points to the file in my output directory, my database copies if newer. VS 2017, if you need anymore information I will edit
Anyone got any leads?
For school coursework
I'm beginner to visual studio and I want to create local DB for c# project
so i installed sql server compact/sqllite for it
after installing it I created a new connection. Then build table
and then executed the table to see option of table I created under drop down menu "table"
I don't understand how to edit that table
when I select edit top 200 rows I see the screen as in image
just one rows. I can't see 200 rows
and on top of that I can't even write in column
is there any special way to do it
or did I miss something that I should have done
'Edit top 200 rows' means edit the data, not the table design (known as the table schema). If there's no data in the table—which if you just created it sounds like the case—you'll need to enter some before you can edit it.
You enter data in Visual Studio by clicking the cell that you want to edit.
Visual Studio 2015 no longer supports design tools for SQL Server CE, so you probably created a SQL Server LocalDB file instead (note no space in the word). That said, you can install Erik EJ's excellent SQL Server CE/SQLite ToolBox extension (more info here).
I am using a SQL Server Compact database for a project I am working on and have been having a hard time trying to insert data to the database.
My insert statement and everything is working fine and data gets inserted too and I can even do searches for the inserted data (while in the application).
The problem I am having is when I quit and re-run the application, it seems that the data was not inserted into the database and the tables are empty too.
Can anyone let me know where I am going wrong with this?
Thanks
Could it be that the SDF file is overwritten with an empty version whenever you rebuild/run the application?
As Thorsten pointed out, check the Build Action on your SDF file.
I have a environment called (Local) and other (Back-up).
From back-up database I have some stored procedures as well as tables which are populated.
In my local I have those stored procedures and table but nothing is stored in them.
So I want to get data from my back-up environment to my local DB environment, how may I achieve this?
I am using SQL Server
There are a few good options listed in other answers. But depending on how often you need to do this activity or how granular control you need, Red Gate's SQL Data Compare let's you compare databases and determine what data should be moved, which direction. Very powerful and easy to use. It's not cheap: starts at $400US but there is a 14 day trial available.
I have no affiliation to them, I'm just a very satisfied customer.
If you want to get only the data in the database, one way to do it in MS SQL Server Management Studio is to export the data from one source to another.
Right-Click on the source database, select "tasks", then select "export data" and follow the instructions of the wizard. It is possible you need to modify some settings such as "identity insert".
To handle the structure of the database, you can generate scripts, namely,
Right-Click on the source database, select "tasks", then select "generate scriptis"
In the end, you can always do a backup / restore of your "back up" db over your local db.
Right-click on the source database, select "tasks", then select "back up..." and follow the instructions of the wizard. In this case, you will want to back up to a file
Afterward, you can restore it using a similar way.
Right-click on the dest database, select "tasks", then select restore. In this case, you will want to select to restore from file.
I hope this helps.
I would recommend using SSIS ("Import Data" from Management Studio) to copy the table data. (in SQL Management Studio, right-click your DB and choose Tasks->Import)
The Stored Procedures are better (IMO) being imported via a SQL Script (in SQL Management Studio, right click the DB and choose Tasks, "Generate Scripts". Note: getting your SPs via SQL will not import any permissions by default.
I would sugest creating SSIS(ETL) package. It's very powerful tool and not Ad-hoc solution like Redgate SQL Data Compare or backup/restore.
In larger enviroinment I would recommend Replication, but it's much bigger topic.
to export data from one DB to another if they have same schemas is very easy. u just have use the impot export wizard inbuild in ssms and specify the source and destination DB's and the select the list of tables to be copied
watch this video
www.youtube.com%2Fwatch%3Fv%3DeDfhTPU7P-M&ei=DUhwULvhM4LPrQeY9oDoCA&usg=AFQjCNGA5a1o-yL9z-31EQQAQed-r5Pvlg&sig2=SiSTQ9tDackePFXw9-5vmw
I can't understand how to manage database with Entity Framework.
I'll try to describe my problem step-by-step
create winforms application
add database (.mdf) to solution
when appears window "choosing database model", select dataset
then finish, as database is empty
go to server explorer, choose created database, create some tables
add to solution EDM ADO.NET
The problem is that new data doesn't appear in my database in server explorer. This means that while my Winforms app is working, I can modify my database (change existing values, add new, ..). but if I close my app, there is no update in my database in server explorer. I DON'T forget to use function SaveChanges()
P.S. while my app is working, values are updating. Think, that means that data updates in dataset, but not in database. if i am right, give a clue how to update database from dataset.
pps. visual studio 2010 ultimate. sorry for english
dbentity db=new dbentity();
db.items.addobject(new item() {value=something});
db.savechanges();
Don't add the database to your solution. You can use the Server Explorer to add a connection to your database via your existing SQL Server, or you can select your database in the wizard that appears when adding a new EDMX file to your solution.
Did you try either of these? Where did you get stuck?