473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQLServer CE deletes or looses files after insert

Hello All:

I am using a the following code to insert some values into CE edition
database running on the Desktop.This code works fine as far as inserting the
new record
the problem arises after the app has been shut down. After restarting the
app all the data in DB is gone. Any ideas on what I am doing wrong

conn = new SqlCeConnection("Data Source = MyDatabase#1.sdf");
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO ExponentialHistory_S(Period,
SalesY1, SalesY2,SalesY3, FileName, Error, A, B) VALUES (?,?,?,?,?,?,?,?)";

cmd.Parameters.Add(new SqlCeParameter("p1", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p2", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p3", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p4", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p5", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p6", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p7", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p8", SqlDbType.NVarChar));

cmd.Parameters["p1"].Value = dgMain[0, 0].Value;
cmd.Parameters["p2"].Value = dgMain[1, 0].Value;
cmd.Parameters["p3"].Value = dgMain[2, 0].Value;
cmd.Parameters["p4"].Value = dgMain[3, 0].Value;
cmd.Parameters["p5"].Value = UseFileName;
cmd.Parameters["p6"].Value = dgMain[4, 0].Value;
cmd.Parameters["p7"].Value = dgMain[5, 0].Value;
cmd.Parameters["p8"].Value = dgMain[6, 0].Value;

cmd.ExecuteNonQuery();
Mar 30 '07 #1
1 1474
Before you rerun the app, is the data in the database? There's a checkbox
somewhere that says "copy a new version over" or something like that, and
it does it every time you run your app.

Robin S.
---------------------
"Tantalus" <Ta******@discussions.microsoft.comwrote in message
news:55**********************************@microsof t.com...
Hello All:

I am using a the following code to insert some values into CE edition
database running on the Desktop.This code works fine as far as inserting
the
new record
the problem arises after the app has been shut down. After restarting the
app all the data in DB is gone. Any ideas on what I am doing wrong

conn = new SqlCeConnection("Data Source = MyDatabase#1.sdf");
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO ExponentialHistory_S(Period,
SalesY1, SalesY2,SalesY3, FileName, Error, A, B) VALUES
(?,?,?,?,?,?,?,?)";

cmd.Parameters.Add(new SqlCeParameter("p1",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p2",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p3",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p4",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p5",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p6",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p7",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("p8",
SqlDbType.NVarChar));

cmd.Parameters["p1"].Value = dgMain[0, 0].Value;
cmd.Parameters["p2"].Value = dgMain[1, 0].Value;
cmd.Parameters["p3"].Value = dgMain[2, 0].Value;
cmd.Parameters["p4"].Value = dgMain[3, 0].Value;
cmd.Parameters["p5"].Value = UseFileName;
cmd.Parameters["p6"].Value = dgMain[4, 0].Value;
cmd.Parameters["p7"].Value = dgMain[5, 0].Value;
cmd.Parameters["p8"].Value = dgMain[6, 0].Value;

cmd.ExecuteNonQuery();


Apr 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Santo Santis | last post by:
How can I make an .exe file that can insert data automatically in a SQLServer database, I can do it in C, but how can I connect to SQLServer and execute a query. All data that I have to insert...
2
by: schumacker | last post by:
Hi everyone! I am working with Delphi v7 and MS SQLServer. I am trying to insert data in a table with a SQL sentence. Some of the fields of my table are type char or varchar, and they can have...
8
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
3
by: Devonish | last post by:
I am planning to convert an existing Access database which has a back end (data tables and relationships only) on a server and a copy of the front end (form, queries, reports) on each of about a...
0
by: how can i insert a image to SQLServer? | last post by:
I want to insert some strings and images which from richTextBox into SQLServer. I could insert it into SQLServer,such as follows: FileStream s=new FileStream...
4
by: Renato Vieira | last post by:
Is there a way of insert or update images (*.gif or *.jpg) in a image field of a SQLServer table without using code? Some sort of small application can do that? by supplying the filename maybe? ...
5
by: JSParker1 | last post by:
Summary: Maximum number of records per second that can be inserted into SQLServer 2000. I am trying to insert hundreds (preferably even thousands) of records per second in to SQLServer table...
2
by: hikums | last post by:
Hi, Can someone recommend a better approach, I already have clustered indexes on the t1 column in table td. This takes more than 30 hours to complete!! The slowdown is with deletes within the...
1
by: mark mestrom | last post by:
Hi all, i have a problem. In my access-application i am trying to insert a record in a linked table with resides in a sqlserver 2000 database. However, the primary key in that table is an INT with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.