Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: binary database Pin
harold aptroot9-May-10 6:09
harold aptroot9-May-10 6:09 
AnswerRe: binary database Pin
Alex Manolescu9-May-10 9:11
Alex Manolescu9-May-10 9:11 
Questionhow to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 4:47
bacem smari9-May-10 4:47 
AnswerRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 9:13
Stanciu Vlad9-May-10 9:13 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 20:26
bacem smari9-May-10 20:26 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 20:28
Stanciu Vlad9-May-10 20:28 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 21:06
bacem smari9-May-10 21:06 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 21:25
Stanciu Vlad9-May-10 21:25 
I think that:
a) you connection is not opened
b) yout command is not attached to that connection
c) adding twice the com parameter does not solve anything
d) the @dat parameter should by datetime

Most probably this code should work:

private void menuItem4_Click(object sender, EventArgs e)
{
   // define the connection string
   string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
  
   // create a connection - this way it will be disposed and closed at the en of the using block
   using(SqlCeConnection sqlceconn = new SqlCeConnection(wCS))
   {
      // define the insert statement
      string insertString = "INSERT INTO compteurs2 ([com], [quantite],[datequantite] ) Values(@com,@qtte,@dat)";

      // create the command based on the insert string and the connection
      SqlCeCommand command2 = sqlceconn.CreateCommand(insertString, sqlceconn);
      
      // define the parameters
      SqlCeParameter com = new SqlCeParameter("@com", SqlDbType.NVarChar);
      SqlCeParameter qtte = new SqlCeParameter("@qtte", SqlDbType.Float);
      SqlCeParameter dat = new SqlCeParameter("@dat", SqlDbType.DateTime);

      // attach values to these parameters
      com.Value = comComboBox.SelectedItem.ToString();
      qtte.Value = float.Parse(textBox1.Text);
      dat.Value = DateTime.Now;

      // attach the parameters to the command
      command2.Parameters.Add(com);
      command2.Parameters.Add(qtte);
      command2.Parameters.Add(dat);

      // open the conenction
      command2.Connection.Open();
      // execute the insert
      command2.ExecuteNonQuery();
   }
   // note that here the connection is closed
}

I have no smart signature yet...

GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 21:37
bacem smari9-May-10 21:37 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 21:57
Stanciu Vlad9-May-10 21:57 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 22:15
bacem smari9-May-10 22:15 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 22:23
Stanciu Vlad9-May-10 22:23 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
bacem smari9-May-10 22:31
bacem smari9-May-10 22:31 
GeneralRe: how to insert a new line in a table of a .sdf file smart device application Pin
Stanciu Vlad9-May-10 22:38
Stanciu Vlad9-May-10 22:38 
QuestionMessage Removed Pin
9-May-10 4:13
Sr...Frank9-May-10 4:13 
AnswerRe: Close All Child Window on Menu Click! Pin
Not Active9-May-10 4:48
mentorNot Active9-May-10 4:48 
AnswerRe: Close All Child Window on Menu Click! Pin
Heinzzy9-May-10 5:47
Heinzzy9-May-10 5:47 
GeneralRe: Close All Child Window on Menu Click! Pin
Sr...Frank9-May-10 6:36
Sr...Frank9-May-10 6:36 
GeneralRe: Close All Child Window on Menu Click! Pin
Luc Pattyn9-May-10 6:41
sitebuilderLuc Pattyn9-May-10 6:41 
GeneralRe: Close All Child Window on Menu Click! Pin
Not Active9-May-10 9:48
mentorNot Active9-May-10 9:48 
Question"Search row" in DataGridView Pin
eyalbi0079-May-10 2:52
eyalbi0079-May-10 2:52 
QuestionRemote Data Acces RDA not allowed in csharp smart device,???? Pin
Tunisien869-May-10 2:05
Tunisien869-May-10 2:05 
AnswerRe: Remote Data Acces RDA not allowed in csharp smart device,???? Pin
Stanciu Vlad9-May-10 9:30
Stanciu Vlad9-May-10 9:30 
GeneralRe: Remote Data Acces RDA not allowed in csharp smart device,???? Pin
Tunisien869-May-10 10:16
Tunisien869-May-10 10:16 
GeneralRe: Remote Data Acces RDA not allowed in csharp smart device,???? Pin
Stanciu Vlad9-May-10 10:28
Stanciu Vlad9-May-10 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.