Quantcast
Channel: SQL Server Compact Forum
Viewing all articles
Browse latest Browse all 193

SQL CE, values aren't written to DB

$
0
0

Hello

I'm creating simple Windows Phone 7.1 SDK application

I need to create small database. To do so, I've installed SQL Server Compact Toolbox. I've created table named TrainingData, which contains 3 columns: ID(PK, int, not null) identity (autoincrements), Data (datetime, null), Time(nchar(15),null). After creating table I've used option Add Windows Phone Data Context to current project, which automatically created TrainingDBContext.

Now, in one page I want to save data to database on click:

private void btnSaveActivity_Click(object sender, RoutedEventArgs e)
        {
            using (TrainingDBContext context = new TrainingDBContext(TrainingDBContext.ConnectionString))
            {
                DateTime date = DateTime.Now;
                context.TrainingData.InsertOnSubmit();
            }
        }

The problem is, context sees ontly TrainingData. I can't access to data column this way: context.data.InsertOnSubmit(date) which throws this error:

Error    1    'PhoneApp1.TrainingDBContext' does not contain a definition for 'data' and no extension method 'data' accepting a first argument of type 'PhoneApp1.TrainingDBContext' could be found (are you missing a using directive or an assembly reference?)

Anyone knows solution to this problem?

Best regards

Raston




Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>