当前位置: 首页>>代码示例>>C#>>正文


C# SqlCeCommand.ExecuteNonQuery方法代码示例

本文整理汇总了C#中SqlCeCommand.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCeCommand.ExecuteNonQuery方法的具体用法?C# SqlCeCommand.ExecuteNonQuery怎么用?C# SqlCeCommand.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlCeCommand的用法示例。


在下文中一共展示了SqlCeCommand.ExecuteNonQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDB

        /// <summary>
        /// Create the initial database
        /// </summary>
        private void CreateDB()
        {
            var connection = new SqlCeConnection(this.path);

            try
            {
                var eng = new SqlCeEngine(this.path);
                var cleanup = new System.Threading.Tasks.Task(eng.Dispose);
                eng.CreateDatabase();
                cleanup.Start();
            }
            catch (Exception e)
            {
                EventLogging.WriteError(e);
            }

            connection.Open();
            var usersDB =
                new SqlCeCommand(
                    "CREATE TABLE Users_DB("
                    + "UserID int IDENTITY (100,1) NOT NULL UNIQUE, "
                    + "UserName nvarchar(128) NOT NULL UNIQUE, "
                    + "PassHash nvarchar(128) NOT NULL, "
                    + "Friends varbinary(5000), "
                    + "PRIMARY KEY (UserID));",
                    connection);
            usersDB.ExecuteNonQuery();
            usersDB.Dispose();
            connection.Dispose();
            connection.Close();
        }
开发者ID:novaksam,项目名称:CIS499_C-_IM_Package,代码行数:34,代码来源:DBInteract.cs

示例2: btnDelete_Click

        private void btnDelete_Click(object sender, EventArgs e)
        {
            btnSave.Enabled = false;
            grbDeviceIP.Enabled = false;

            dataSourcePath = "Data Source = " + Application.StartupPath + @"\DeviceData.sdf";
            SqlCeConnection sqlConnection1 = new SqlCeConnection();
            sqlConnection1.ConnectionString = dataSourcePath;
            SqlCeCommand cmd = new SqlCeCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Connection = sqlConnection1;
            sqlConnection1.Open();
            try
            {
                cmd.CommandText = "DELETE FROM DeviceData WHERE DEVICE_IP='" + Global.selMechIp + "'";
                cmd.ExecuteNonQuery();

                cmd.CommandText = "DELETE FROM DeviceURL WHERE DEV_IP='" + Global.selMechIp + "'";
                cmd.ExecuteNonQuery();
            }
            catch { }
            sqlConnection1.Dispose();
            sqlConnection1.Close();
            fnGetIpsFronTable();
            btnDelete.Enabled = false;
            btnEdit.Enabled = false;

            txtDevIp.Text = "";
            txtDevNo.Text = "";
            txtDevPort.Text = "";
            Application.DoEvents();
        }
开发者ID:nagamani-relyon,项目名称:BMDevice_new,代码行数:32,代码来源:frmNewDevice.cs

示例3: CreateApplications

        private static void CreateApplications(SqlCeCommand cmd, string applicationName)
        {
            cmd.CommandText =
                @"CREATE TABLE [aspnet_Applications] (
                        [ApplicationName] nvarchar(256) NOT NULL
                    , [LoweredApplicationName] nvarchar(256) NOT NULL
                    , [ApplicationId] uniqueidentifier NOT NULL DEFAULT (newid()) PRIMARY KEY
                    , [Description] nvarchar(256) NULL
                    );
                        ";
            cmd.ExecuteNonQuery();

            cmd.CommandText =
                @"CREATE INDEX [aspnet_Applications_Index] ON [aspnet_Applications] ([LoweredApplicationName] ASC);";
            cmd.ExecuteNonQuery();

            cmd.CommandText = @"CREATE UNIQUE INDEX [UQ__aspnet_A__3091033107020F21] ON [aspnet_Applications] ([ApplicationName] ASC);";
            cmd.ExecuteNonQuery();

            cmd.CommandText =
                @"INSERT INTO [aspnet_Applications] ([ApplicationName], [LoweredApplicationName] ,[ApplicationId])
                    VALUES
                    (@ApplicationName
                    ,@LoweredApplicationName
                    ,@ApplicationId
                    );
            ";
            cmd.Parameters.Add("@ApplicationName", SqlDbType.NVarChar, 256).Value = applicationName;
            cmd.Parameters.Add("@LoweredApplicationName", SqlDbType.NVarChar, 256).Value = applicationName.ToLowerInvariant();
            cmd.Parameters.Add("@ApplicationId", SqlDbType.UniqueIdentifier).Value = Guid.NewGuid();
            cmd.ExecuteNonQuery();
        }
开发者ID:brianlpope,项目名称:MediumTrustMVCWebsite,代码行数:32,代码来源:SqlCeMembershipUtils.cs

示例4: clearTables

        public void clearTables()
        {
            SqlCeCommand deleteCommand = new SqlCeCommand("DELETE FROM Patient", this._conn);
            deleteCommand.ExecuteNonQuery();
            deleteCommand.CommandText = "DELETE FROM Visit";
            deleteCommand.ExecuteNonQuery();

            SqlCeCommand alterTableCommand = new SqlCeCommand("ALTER TABLE Patient alter column id IDENTITY(1,1)", this._conn);
            alterTableCommand.ExecuteNonQuery();
            alterTableCommand.CommandText = "ALTER TABLE Visit alter column id IDENTITY(1,1)";
            alterTableCommand.ExecuteNonQuery();
        }
开发者ID:patpaquette,项目名称:Cheo-visits,代码行数:12,代码来源:DbMethods.cs

示例5: CrearConexion

        //AñadirPago
        public void AñadirNuevo(PagoEntrante pagEntr)
        {
            //Crear Conexion y Abrirla
            SqlCeConnection Con = CrearConexion();

            // Crear SQLCeCommand - Asignarle la conexion - Asignarle la instruccion SQL (consulta)
            SqlCeCommand Comando = new SqlCeCommand();
            Comando.Connection = Con;
            Comando.CommandType = CommandType.Text;

            Comando.CommandText = "INSERT INTO [PagosEntrantes] ([idTramite], [dniCuilCliente], [fecha], [valor], [detalle]) VALUES (@IDTRAMITE, @DNICUILCLI, @FECHA, @VALOR, @DETALLE)";
            Comando.Parameters.Add(new SqlCeParameter("@IDTRAMITE", SqlDbType.Int));
            Comando.Parameters["@IDTRAMITE"].Value = pagEntr.IdTramite;
            Comando.Parameters.Add(new SqlCeParameter("@DNICUILCLI", SqlDbType.NVarChar));
            Comando.Parameters["@DNICUILCLI"].Value = pagEntr.DniCuilCliente;
            Comando.Parameters.Add(new SqlCeParameter("@FECHA", SqlDbType.DateTime));
            Comando.Parameters["@FECHA"].Value = pagEntr.Fecha;
            Comando.Parameters.Add(new SqlCeParameter("@VALOR", SqlDbType.Money));
            Comando.Parameters["@VALOR"].Value = pagEntr.Valor;
            Comando.Parameters.Add(new SqlCeParameter("@DETALLE", SqlDbType.NVarChar));
            Comando.Parameters["@DETALLE"].Value = pagEntr.Detalle;

            //Ejecuta el comando INSERT
            Comando.Connection.Open();
            Comando.ExecuteNonQuery();
            Comando.Connection.Close();
        }
开发者ID:dantearrighi,项目名称:WASSDiploma,代码行数:28,代码来源:PagosEntrantesAdapter.cs

示例6: CreateUser

        public static User CreateUser(string username, string password)
        {
            SqlCeConnection con = new SqlCeConnection(CONNECTION_STRING);
            try
            {
                con.Open();
                SqlCeCommand comm = new SqlCeCommand("INSERT INTO users (username, password, salt, dateCreated) VALUES (@username, @password, @salt, @createdDate)", con);
                comm.Parameters.Add(new SqlCeParameter("@username", username));
                comm.Parameters.Add(new SqlCeParameter("@password", password));
                comm.Parameters.Add(new SqlCeParameter("@salt", String.Empty));
                comm.Parameters.Add(new SqlCeParameter("@createdDate", DateTime.UtcNow));

                int numberOfRows = comm.ExecuteNonQuery();
                if (numberOfRows > 0)
                {
                    return GetUser(username);
                }
            }
            catch (Exception ex)
            {
                Debug.Print("CreateUser Exception: " + ex);
            }
            finally
            {
                if (con != null && con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }

            return null;
        }
开发者ID:reedyrm,项目名称:am_backend,代码行数:32,代码来源:UserDataService.cs

示例7: Listen

        static void Listen()
        {
            //[ClientID],[pNumber],[msg],[move],[start board]
            while (true)
            {
                string sql;
                string rcvd = Console.ReadLine();

                if (rcvd.Split('¬')[2].StartsWith("cht:"))
                {
                    sql = "insert into history(ClientID,name,message,status) values (" + System.Diagnostics.Process.GetCurrentProcess().Id + ",'" + name + "','" + msg.Substring(4) + "','N')";
                    SqlCeCommand command = new SqlCeCommand(sql, m_dbConnection);
                    command.ExecuteNonQuery();
                }

                if (rcvd.Split('¬')[2].StartsWith("lst:"))
                {
                    sql = "SELECT * FROM Session where clientID2 is null";
                    SqlCeCommand command = new SqlCeCommand(sql, m_dbConnection);
                    command.CommandText = sql;
                    command.CommandType = System.Data.CommandType.Text;
                    SqlCeDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Console.WriteLine("¬" + reader["message"].ToString() + "¬");
                    }
                }
            }
        }
开发者ID:xiico,项目名称:hungry,代码行数:29,代码来源:Program.cs

示例8: registriraj

    public bool registriraj(string korisnickoIme, string lozinka, string address, string email)
    {
        SqlCeConnection conn = new SqlCeConnection(connString);
        try
        {
            Random r = new Random(System.DateTime.Now.Millisecond);

            string salt = r.Next().ToString();
            string hashiranaLoznika = Util.SHA256(lozinka);
            string hashiranaSlanaLoznika = Util.SHA256(salt + hashiranaLoznika);

            conn.Open();

            SqlCeCommand command = new SqlCeCommand
                ("INSERT INTO Kori(username,password,salt,address,email) VALUES (@username,@password,@salt,@address,@email)",conn);
            command.Parameters.AddWithValue("username", korisnickoIme);
            command.Parameters.AddWithValue("password", hashiranaSlanaLoznika);
            command.Parameters.AddWithValue("salt", salt);
            command.Parameters.AddWithValue("address", address);
            command.Parameters.AddWithValue("email", email);

            command.ExecuteNonQuery();
            conn.Close();
            return true;
        }

        catch (Exception ex)
        {
            return false;
        }
    }
开发者ID:madmax17,项目名称:Pin,代码行数:31,代码来源:Registracija2.aspx.cs

示例9: Actualizar

        public void Actualizar(Entidades.Cliente cli, string dniActual)
        {
            //Crear Conexion y Abrirla
            SqlCeConnection Con = CrearConexion();

            // Crear SQLCeCommand - Asignarle la conexion - Asignarle la instruccion SQL (consulta)
            SqlCeCommand Comando = new SqlCeCommand();
            Comando.Connection = Con;
            Comando.CommandType = CommandType.Text;

            Comando.CommandText = "UPDATE [Clientes] SET [dnicuil][email protected],[nombre] = @NOMBRE, [apellido] = @APELLIDO, [email] = @EMAIL, [tel1][email protected], [tel2][email protected] WHERE (([dnicuil] = @DNICUILACTUAL))";
            Comando.Parameters.Add(new SqlCeParameter("@DNICUILACTUAL", SqlDbType.NVarChar));
            Comando.Parameters["@DNICUILACTUAL"].Value = dniActual;
            Comando.Parameters.Add(new SqlCeParameter("@NOMBRE", SqlDbType.NVarChar));
            Comando.Parameters["@NOMBRE"].Value = cli.Nombre;
            Comando.Parameters.Add(new SqlCeParameter("@APELLIDO", SqlDbType.NVarChar));
            Comando.Parameters["@APELLIDO"].Value = cli.Apellido;
            Comando.Parameters.Add(new SqlCeParameter("@EMAIL", SqlDbType.NVarChar));
            Comando.Parameters["@EMAIL"].Value = cli.Email;
            Comando.Parameters.Add(new SqlCeParameter("@TEL1", SqlDbType.NVarChar));
            Comando.Parameters["@TEL1"].Value = cli.Tel1;
            Comando.Parameters.Add(new SqlCeParameter("@TEL2", SqlDbType.NVarChar));
            Comando.Parameters["@TEL2"].Value = cli.Tel2;
            Comando.Parameters.Add(new SqlCeParameter("@DNINuevo", SqlDbType.NVarChar));
            Comando.Parameters["@DNINuevo"].Value = cli.DniCuil;

            //Ejecuta el comando INSERT
            Comando.Connection.Open();
            Comando.ExecuteNonQuery();
            Comando.Connection.Close();
        }
开发者ID:dantearrighi,项目名称:WASSDiploma,代码行数:31,代码来源:ClienteAdapter.cs

示例10: Clean

		private static void Clean(string tableName)
		{
			if (!Program.Settings.General.UseCachedResults)
				return;

			string getMaxIDSql = string.Format("select max(ID) from {0};", tableName);
			long? maxID = null;

			using (SqlCeCommand cmd = new SqlCeCommand(getMaxIDSql, Program.GetOpenCacheConnection()))
			using (SqlCeDataAdapter da = new SqlCeDataAdapter(cmd))
			{
				DataSet ds = new DataSet();
				da.Fill(ds);

				if (ds.Tables[0].Rows.Count == 1)
				{
					if (!DBNull.Value.Equals(ds.Tables[0].Rows[0][0]))
						maxID = Convert.ToInt64(ds.Tables[0].Rows[0][0]);
				}
			}

			if (maxID != null)
			{
				maxID -= Program.Settings.General.CacheSize;
				if (maxID > 0)
				{
					string deleteSql = string.Format("delete from {0} where ID <= {1};", tableName, maxID);
					using (SqlCeCommand cmd = new SqlCeCommand(deleteSql, Program.GetOpenCacheConnection()))
					{
						cmd.ExecuteNonQuery();
					}
				}
			}
		}
开发者ID:neurocache,项目名称:ilSFV,代码行数:34,代码来源:Cache.cs

示例11: Clear

 public void Clear()
 {
     conn.Open();
     var cmd = new SqlCeCommand("DELETE FROM Words", conn);
     cmd.ExecuteNonQuery();
     conn.Close();
 }
开发者ID:roeibux,项目名称:text-predict,代码行数:7,代码来源:DataBase.cs

示例12: Add

        public bool Add(string nameEmail, string addressEmail, string typeEmail, bool quickEmail)
        {
            nameEmail = nameEmail.Trim();

            if (CheckDuplicate(addressEmail))
                return false; // Denne adresse finnes allerede

            try
            {
                con.Open();
                using (SqlCeCommand cmd = new SqlCeCommand("insert into tblEmail(Name, Address, Type, Quick) values (@Val1, @val2, @val3, @val4)", con))
                {
                    cmd.Parameters.AddWithValue("@Val1", nameEmail);
                    cmd.Parameters.AddWithValue("@Val2", addressEmail);
                    cmd.Parameters.AddWithValue("@Val3", typeEmail);
                    cmd.Parameters.AddWithValue("@Val4", quickEmail);
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.ExecuteNonQuery();
                }
                con.Close();
                return true;
            }
            catch(Exception ex)
            {
                Log.Unhandled(ex);
                return false;
            }
        }
开发者ID:tborgund,项目名称:kgsa,代码行数:28,代码来源:FormEmailAddressbook.cs

示例13: AddNewAdmin

        public bool AddNewAdmin(string UserName, string Password)
        {
            string commandText = "INSERT INTO AdminInfo(AID, Name, UserName, Password, NICNumber)" +
                "VALUES(@aID, @name, @userName, @password, @nicNumber)";

            using (SqlCeConnection connection = new SqlCeConnection(connectionSting))
            {
                using (SqlCeCommand command = new SqlCeCommand(commandText, connection))
                {
                    try
                    {
                        connection.Open();
                        command.Parameters.AddWithValue("@aID", Guid.NewGuid());
                        command.Parameters.AddWithValue("@name", "");
                        command.Parameters.AddWithValue("@userName", UserName);
                        command.Parameters.AddWithValue("@password", Password);
                        command.Parameters.AddWithValue("@nicNumber", "");
                        command.ExecuteNonQuery();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:Jayendra88,项目名称:Questionnaire,代码行数:29,代码来源:CRUDManager.cs

示例14: Alterar

        public bool Alterar(EMovimentacaoConta movementacaoConta)
        {
            SqlCeConnection cnn = new SqlCeConnection();
            cnn.ConnectionString = Conexao.Caminho;

            SqlCeCommand cmd = new SqlCeCommand();
            cmd.Connection = cnn;

            #region alteracao do associado
            cmd.CommandText = @"UPDATE MovimentacaoConta SET 
                               dataHoraMovimentacao = @dataHoraMovimentacao, 
                               valortotal = @valortotal,
                               Id_Associado = @Id_Associado,
                               Id_Movimentacao = @Id_Movimentacao
                               ListaItens = @ListaItens
                               WHERE Id_Movimentacao = @Id ";

            cmd.Parameters.Add("@Nome", movementacaoConta.DataHoraMovimentacao);
            cmd.Parameters.Add("@valorTotal", movementacaoConta.Valortotal);
            cmd.Parameters.Add("@IdMovimentacao", movementacaoConta.IdAssociado);
            cmd.Parameters.Add("@IdMovimentacao", movementacaoConta.IdMovimentacao);
            cmd.Parameters.Add("@Listaitens", movementacaoConta.ListaItens);

            //Executa o comando setado - UPDATE
            cnn.Open();
            cmd.ExecuteNonQuery();
            #endregion alteracao do associado

            //Fecha a conexão
            cnn.Close();

            return true;
        }
开发者ID:carvalho2209,项目名称:Client,代码行数:33,代码来源:PMovimentacaoConta.cs

示例15: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        //Hash lozinke i salt
        string hashLozinka = Util.hashHash(tb_lozinka.Text);
        //Sol generiraj
        string salt = (new Random(DateTime.Now.Millisecond))
                       .Next()
                       .ToString();
        //hashiraj sve skupa
        string konacniHash = Util.hashHash(hashLozinka + salt);

        //sPOJI SE NA BAZU I spremi korisnika
        string connString = WebConfigurationManager.ConnectionStrings["UsersConnectionString"].ConnectionString;
        SqlCeConnection connection = new SqlCeConnection(connString);
        //kreiraj insert komandu
        SqlCeCommand command = new SqlCeCommand();
        command.Connection = connection;
        command.CommandType = System.Data.CommandType.Text;
        command.CommandText = "INSERT INTO korisnik VALUES(@ime, @lozinka, @salt)";
        //Pročitaj lozinku i ime
        command.Parameters.AddWithValue("ime", tb_kime.Text);
        // No No command.Parameters.AddWithValue("lozinka", tb_lozinka.Text);
        command.Parameters.AddWithValue("lozinka", konacniHash);
        command.Parameters.AddWithValue("salt", salt);
        connection.Open();
        int brojRedova = command.ExecuteNonQuery();
        connection.Close();
        if (brojRedova == 1)
        {
            //Logiraj korisnika
            Session["korisnik"] = tb_kime.Text;
            Response.Redirect("LogiraniKorisnici.aspx");
        } //else labela greška, itd...
    }
开发者ID:vsite-prog,项目名称:PIN,代码行数:34,代码来源:Registracija.aspx.cs


注:本文中的SqlCeCommand.ExecuteNonQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。