Pocket PC FAQ Forums Forum Index Pocket PC FAQ Forums
The place to discuss Windows Mobile, Pocket PCs, Smartphones, Handheld PCs, Windows CE and More!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inserting data into database

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Pocket PC FAQ Forums Forum Index -> SmartPhone Developers
View previous topic :: View next topic  
Author Message
WishIWasSmarter
Pocketeer


Joined: 27 Jan 2009
Posts: 1

PostPosted: Tue Jan 27, 2009 4:15 am    Post subject: Inserting data into database Reply with quote

Please can someone help. I am using VS 2005 and am desperately trying to insert values into a database. I have created a sdf database, connected to it and am now trying to insert some test data. My code looks something like this:

private void Form1_Load(object sender, EventArgs e)
{

FromLoad = true;

connectionString = "Data Source=" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MobileApp.sdf";
cn = new SqlCeConnection(connectionString);
cn.Open();

DataSet MyDataSet = new DataSet();
SqlCeDataAdapter MyDataAdapter = new SqlCeDataAdapter("Select PlayerID, Name, Surname, Surname + ', ' + Name as FullName FROM Player ORDER BY PlayerID", cn);


// fill the DataSet using our DataAdapter into a table called users
MyDataAdapter.Fill(MyDataSet, "Player");

SqlCeCommand cmd = cn.CreateCommand();
MyDataAdapter.InsertCommand = cn.CreateCommand();

cmd.CommandText = "INSERT INTO Player(Name, Surname) VALUES ('Test', 'Data')";
cmd.ExecuteNonQuery();


}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Pocket PC FAQ Forums Forum Index -> SmartPhone Developers All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Copyright 2001-2010, Chris De Herrera, All Rights Reserved

Powered by phpBB © 2001, 2005 phpBB Group