Esempio applicazione dati con SqlCompact

This example shows how to insert, update, and delete the data with sqlcompact, excellent databse for use on a PC client locale.Anche if in its context and a very simple example, I hope will be helpful to all that chlorine look out for the first time

 
 
 
 
 
5 Star
(3)
11,932 times
Add to favorites
7/31/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Non Scrive nel DB
    1 Posts | Last post March 09, 2013
    • Ciao e complimenti per i tuoi esempi.
      Sto provando ad usare un SQL Compact DB ma quando eseguo la query semplicemente non scrive nel DB. Il codice è molto semplice;
      
                  SqlCeConnection connection = new SqlCeConnection();
                 
                  connection.ConnectionString = RefertoWin.Properties.Settings.Default.RefertoConnectionString;
      
                  SqlCeCommand cmd = new SqlCeCommand("INSERT INTO GARA (NUMERO,LOCALITA,CAMPO) VALUES (@NUMERO,@LOCALITA,@CAMPO)", connection);
                  try
                  {
                      cmd.Parameters.AddWithValue("@NUMERO", numero.ToUpper());
                      cmd.Parameters.AddWithValue("@LOCALITA", localita.ToUpper());
                      cmd.Parameters.AddWithValue("@CAMPO", campo.ToUpper());
                      connection.Open();
                      cmd.ExecuteNonQuery();
                      
                      return 0;
                  }
                  catch (Exception ex)
                  {
                      // Visualizzo messaggio errore a ytente
                      MessageBox.Show(ex.Message.ToString());
                      return 0;
                  }
                  finally
                  {
                      connection.Close();
                      connection.Dispose();
                  }
      
      Non da errori: semplicemente non scrive.
      Spero tu possa aiutarmi. 
      
      Marco
      marco@dallalibera.net
  • qualche spiegazione
    1 Posts | Last post December 12, 2012
    • ciao volevo sapere se potevi darmi delle dritte visto che sto creando un software al livello amatoriale grazie.la mia email è totem16@hotmail.com
  • please can you translate this example to english please...
    13 Posts | Last post August 06, 2011
    • I need it .this is the one i searching for but i did not understand the language...THANK YOU VERY MUCH..
    • Hi rose_ann,
      
      I translated the example in English, but if you mean the part of the code relating to comments will placed to translate it. 
      
      Bye, if you need to your disposal for any questions or concerns.
    • yes the comments and codes if can be..
      
      one more question in the SqlCeConnection connection = new SqlCeConnection(@"Data Source = C:\Users\Carmelo La Monica\Documents\Login.sdf;");
      where did I get the datasource?pls reply 
    • Hello rose_ann,
      
      I proceeded to the English translation of the comments and adjusted the names of classes and methods in English.
      As regards your question, you see the srtinga and location of the database Login.sdf in my PC, but you can choose the path that plunder, let me say for example "C: \ rose_ann.Login.sdf".
      If you need to ask quietly.
      
      Best Regards.
    • thank you...if i choose to use the Northwind.sdf the sample given by compact edition 3.5 what is the pathname?it cause error i cannot connect to sqlsercer ce 3.5..thanks..
    • Hello rose_ann,
      
      I wrote the example uses the database Login.sdf with the appropriate fields, if you decide to use the Northwind, you have to adapt the connection path is exactly where the Northwind database, or copy it to another part of the disk and change the path.
      Please note that the tables and fields of the two databases are not the same login and Northwind, so you have to adapt the example and made the classes that reflect the model or tables that you choose to use.
      
      A sample path can be @ "C: \ yourname \ Northwind.sdf"
      
      Best Regards
    • okay thank you very much sir..
      can i make a request sir if you can create project that can add,edit,delete and search buttons in datagridview using database sqlserver ce3 3.5..fields are id,last name and first name.. English if you can.. 
      
      please sir..
      i need it after 2 days..
      
      Thank you.
      GODBless..
    • Hi rose_ann,
      
      I'll try to do everything possible to create a complete and functional example of what already exists, but work takes me away a long time.
      
      Best Regards
    • can i ask?
      the delete one in this code is not running..can you create another ?
      thank you very much take care.
    • sorry it's working already..thank you for that code..can i again did you know the code in deleting by means of choosing the record you want to delete in datagridview and then clicking delete button
      
      and 1 more where can i put a message box in your code when it successfully recorded or delete in the o record?
      
      thank you very much your code is very helpful to me..
      take care. :)
    • Hello Rose_ann,
      
       you can put the message in the class within the Delete Try / Catch block of the Delete method date, and enclose all the code from the query string to the line within a block return true if / else.
       So if you, messageBox, keys and yes / no, if the user presses the yes delete the data, not otherwise do nothing.
      
      Best Regards
    • thanks again sir...
      what is the code in adding record in database using combo box sir?
      like in text box you used in your code what the code for combo box?
    • i have a problem i can't continue my project because of this 
      my project is not updating when i debug it the recent one i do is running not the one i editin c#
      
      if you know the reason and solution please tell me i do not know what i'm go in to do..