SQL CE & C#
-
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
-
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
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
-
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
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? :((