|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Working with database in C# Pocket PCHi all, I want to develop an application that work with DB on pocket PC. I have added the DB to the project from Menu->Data->Add New Data Source. I want to insert some Rows in a table of this Db. I know that I can create a connection and insert values with sql statements like that: public void SaveSettings(TSaveSettings Values) { DBConnection = new SqlCeConnection(); DBConnection.ConnectionString = @"Data Source = ..\My Documents\Db.sdf"; //Create a SqlCeCommand on your connection SqlCeCommand InsertCommand = DBConnection.CreateCommand(); //Set the CommandText for the command //The ?'s represent parameters that will be set later InsertCommand.CommandText = "Insert Into Settings(ComPort) Values (?)"; //Add parameters and assign them the values from the TextBoxes on the form InsertCommand.Parameters.Add(new SqlCeParameter("ComPort", SqlDbType.NText)); InsertCommand.Parameters["ComPort"].Value = Values.ComPort; //Open the connection, execute the query DBConnection.Open(); InsertCommand.ExecuteNonQuery(); //Close the connection if (DBConnection.State == ConnectionState.Open) DBConnection.Close(); } in this way it work, but why I have added the Db to the project? I want from my application to make operation on my DB without creating connection, open it and close it by code, but I want to use smoe things like dataset, adding rows by rows.add().. and so on. Can you help me with some examples or tutorials on line? thank you very much On Apr 6, 3:00 pm, "Sheikko" <shei***@gmail.com> wrote: What do you meant? Can you make it clear?> Working with database in C# Pocket PC > in this way it work, but why I have added the Db to the project? I I'm not sure exactly what you're asking, but tutorials are available here:
http://www.microsoft.com/sql/editions/compact/default.mspx -- Show quoteGinny "Sheikko" <shei***@gmail.com> wrote in message news:1175857251.222744.245190@l77g2000hsb.googlegroups.com... > Working with database in C# Pocket PC > > Hi all, > I want to develop an application that work with DB on pocket PC. > I have added the DB to the project from Menu->Data->Add New Data > Source. > I want to insert some Rows in a table of this Db. > I know that I can create a connection and insert values with sql > statements like that: > > public void SaveSettings(TSaveSettings Values) > { > > DBConnection = new SqlCeConnection(); > DBConnection.ConnectionString = @"Data Source = ..\My > Documents\Db.sdf"; > > //Create a SqlCeCommand on your connection > SqlCeCommand InsertCommand = DBConnection.CreateCommand(); > > //Set the CommandText for the command > //The ?'s represent parameters that will be set later > InsertCommand.CommandText = "Insert Into Settings(ComPort) > Values (?)"; > > //Add parameters and assign them the values from the > TextBoxes on the form > InsertCommand.Parameters.Add(new SqlCeParameter("ComPort", > SqlDbType.NText)); > > InsertCommand.Parameters["ComPort"].Value = > Values.ComPort; > > //Open the connection, execute the query > DBConnection.Open(); > InsertCommand.ExecuteNonQuery(); > > //Close the connection > if (DBConnection.State == ConnectionState.Open) > DBConnection.Close(); > } > > in this way it work, but why I have added the Db to the project? I > want from my application to make operation on my DB without creating > connection, open it and close it by code, but I want to use smoe > things like dataset, adding rows by rows.add().. and so on. > > Can you help me with some examples or tutorials on line? > thank you very much > |
|||||||||||||||||||||||