Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SQL CE & C#

SQL CE & C#

Scheduled Pinned Locked Moved C#
databasecsharpsql-serversysadmintesting
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    three leaf
    wrote on last edited by
    #1

    Hi, i'm new in this forum. I am currently developing a Pocket Application using C# & SQL CE. Now, everything was working fine until just now. When I do any type of operations in the database (insert, update & delete) running the application in the device everything goes right, no errors. But When I check the database, no changes has been made. It seems that everything is working but I do not know if I'm missing something. I didn't noticed this until i was testing my RDA functions, when i realized that the tables didn't have any data of the SQL Server, any idea of how to solve this? this class creates connections to the SQL CE database.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data.SqlServerCe;
    using System.Data.SqlClient;
    using System.Windows;
    using System.IO;
    using CAPocket.Clases;

    namespace CAPocket.Clases
    {
    class Data
    {
    String cadenaCon;
    public Data()
    {
    cadenaCon = @"Data Source =\Program Files\CAPocket\Sistema.sdf;SSCE:Database Password='pam653045';";
    }

        public SqlCeConnection GetConnection()
        {
            SqlCeConnection con = new SqlCeConnection(cadenaCon);
            try
            {
                con.Open();
                return con;
            }
            catch (SqlCeException ex)
            {
                return null;
            }
        }
    
        public SqlCeDataAdapter getAdapter(String s\_sql)
        {
            SqlCeDataAdapter adp;
            try
            {
                adp = new SqlCeDataAdapter(s\_sql, cadenaCon);
                return adp;
            }
            catch (SqlCeException ex)
            { return null; }
        }
    
    }
    

    }

    This code block of a class allows the administrator to add, delete or get all the users registered in the application:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data.SqlServerCe;
    using System.Data.SqlClient;
    using System.Windows;
    using System.IO;
    using System.Data;
    using CAPocket.Clases;

    namespace CAPocket
    {
    class GestionUsuarios
    {
    public GestionUsuarios()
    {

        }
        Data cex;
        SqlCeConnection cnn;
        SqlCeCommand cmd;
        //Agrega un nuevo usuario al sistema
        public bool NuevoUsuario(String user, String pass, String tipo)
        {
            cex = new Data();
            cnn = cex.GetConnection();
            if (cnn != null
    
    N 1 Reply Last reply
    0
    • T three leaf

      Hi, i'm new in this forum. I am currently developing a Pocket Application using C# & SQL CE. Now, everything was working fine until just now. When I do any type of operations in the database (insert, update & delete) running the application in the device everything goes right, no errors. But When I check the database, no changes has been made. It seems that everything is working but I do not know if I'm missing something. I didn't noticed this until i was testing my RDA functions, when i realized that the tables didn't have any data of the SQL Server, any idea of how to solve this? this class creates connections to the SQL CE database.

      using System;
      using System.Collections.Generic;
      using System.Text;
      using System.Data.SqlServerCe;
      using System.Data.SqlClient;
      using System.Windows;
      using System.IO;
      using CAPocket.Clases;

      namespace CAPocket.Clases
      {
      class Data
      {
      String cadenaCon;
      public Data()
      {
      cadenaCon = @"Data Source =\Program Files\CAPocket\Sistema.sdf;SSCE:Database Password='pam653045';";
      }

          public SqlCeConnection GetConnection()
          {
              SqlCeConnection con = new SqlCeConnection(cadenaCon);
              try
              {
                  con.Open();
                  return con;
              }
              catch (SqlCeException ex)
              {
                  return null;
              }
          }
      
          public SqlCeDataAdapter getAdapter(String s\_sql)
          {
              SqlCeDataAdapter adp;
              try
              {
                  adp = new SqlCeDataAdapter(s\_sql, cadenaCon);
                  return adp;
              }
              catch (SqlCeException ex)
              { return null; }
          }
      
      }
      

      }

      This code block of a class allows the administrator to add, delete or get all the users registered in the application:

      using System;
      using System.Collections.Generic;
      using System.Text;
      using System.Data.SqlServerCe;
      using System.Data.SqlClient;
      using System.Windows;
      using System.IO;
      using System.Data;
      using CAPocket.Clases;

      namespace CAPocket
      {
      class GestionUsuarios
      {
      public GestionUsuarios()
      {

          }
          Data cex;
          SqlCeConnection cnn;
          SqlCeCommand cmd;
          //Agrega un nuevo usuario al sistema
          public bool NuevoUsuario(String user, String pass, String tipo)
          {
              cex = new Data();
              cnn = cex.GetConnection();
              if (cnn != null
      
      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Put break points and step into to the code.

      three.leaf wrote:

      "select * from Usuarios where Usuario='" + user + "'";

      three.leaf wrote:

      "insert into Usuarios values ('" + user + "','" + pass + "', '" + tipo + "')";

      Ahh , SQL injection. Read this[^]

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      T 1 Reply Last reply
      0
      • N N a v a n e e t h

        Put break points and step into to the code.

        three.leaf wrote:

        "select * from Usuarios where Usuario='" + user + "'";

        three.leaf wrote:

        "insert into Usuarios values ('" + user + "','" + pass + "', '" + tipo + "')";

        Ahh , SQL injection. Read this[^]

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        T Offline
        T Offline
        three leaf
        wrote on last edited by
        #3

        I put the break points, and step into the code but still, not working. While I run it in the emulator, it adds the data to the mobile database, but after i stop the debugging and restart the application, the data is lost. Any other idea? :((

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups