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


C# SqlCeDataAdapter.Update方法代码示例

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


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

示例1: DeleteFolderFromDB

 public static void DeleteFolderFromDB(string folderPath, string dbFilePath)
 {
     using (SqlCeConnection con = CreateConnection(dbFilePath))
     {
         con.Open();
         SqlCeDataAdapter da = new SqlCeDataAdapter("Select * FROM Folders", con);
         da.DeleteCommand = new SqlCeCommand(
             "DELETE FROM Folders WHERE id = @original_id " +
             "and name = @original_name");
         da.DeleteCommand.Parameters.Add("@original_id", SqlDbType.Int, 0, "id");
         da.DeleteCommand.Parameters.Add("@original_name", SqlDbType.NVarChar, 255, "name");
         da.DeleteCommand.Connection = con;
         DataSet ds = new DataSet("Folder");
         DataTable dt = new DataTable("Folders");
         dt.Columns.Add(new DataColumn("id", typeof(int)));
         dt.Columns.Add(new DataColumn("name", typeof(string)));
         ds.Tables.Add(dt);
         da.Fill(ds, "Folders");
         int ind = -1;
         for (int i = 0; i < folderList.Count; i++)
         {
             if (folderList[i] == folderPath.Replace("'", "`"))
             {
                 ind = i;
                 break;
             }
         }
         string folderid = ds.Tables["Folders"].Rows[ind]["id"].ToString();
         dt.Rows[ind].Delete();
         da.Update(ds, "Folders");
         string sql = "DELETE FROM Songs WHERE folder_id = " + folderid;
         SqlCeCommand com = new SqlCeCommand(sql, con);
         com.ExecuteNonQuery();
     }
 }
开发者ID:kostyakozko,项目名称:myplayer,代码行数:35,代码来源:FolderProcessing.cs

示例2: updateDatabase

 private void updateDatabase()
 {
     SqlCeCommand cmd = new SqlCeCommand(CmdString, con);
     SqlCeDataAdapter sda = new SqlCeDataAdapter(cmd);
     SqlCeCommandBuilder com = new SqlCeCommandBuilder(sda);
     DataSet ds = new DataSet();
     sda.Update(dt);
     dt.Clear();
     sda.Fill(dt);
 }
开发者ID:jcalton88,项目名称:CustomerManagement,代码行数:10,代码来源:MainWindow.xaml.cs

示例3: ChangeSetting_Click

        private void ChangeSetting_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SqlCeCommand cmd = thisConnection.CreateCommand();
                cmd.CommandText = "UPDATE Patient SET Setting = \'" + SettingTxt.Text + "\' WHERE PtID=0 , EquipID=1, Control='Lever'" ;

                SqlCeDataAdapter adp = new SqlCeDataAdapter(cmd);
                DataSet ds = new DataSet();
                adp.Update(ds.Tables[0]);
                //PatientView.DataContext = ds.Tables[0];

                //rdr.Close();
                cmd.Dispose();
            }
            catch (SqlException err)
            {
                Console.WriteLine(err.Message);
            }
        }
开发者ID:nmrabinovich,项目名称:AugMed_repo,代码行数:20,代码来源:ModSetting.xaml.cs

示例4: Datagridconfiguration_CurrentCellChanged

        private void Datagridconfiguration_CurrentCellChanged(object sender, EventArgs e)
        {
            using (SqlCeConnection cn = new SqlCeConnection(CAN_Monitor_Functions._connstring))
            {
                try
                {
                    //MessageBox.Show(dtconfiguration.TableName);
                    sda = new SqlCeDataAdapter(string.Format("SELECT * FROM {0}", datatablescolumn.Rows[Comboboxconfiguration.SelectedIndex][0].ToString()), cn);

                    sbuilder = new SqlCeCommandBuilder(sda);

                    sda.Update(dtconfiguration);




                }
                catch (SqlCeException sqlex)
                {
                    MessageBox.Show(sqlex.Message, "fail with filling dataset");

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }

        }
开发者ID:TeamVader,项目名称:CANBUS_MONITOR,代码行数:30,代码来源:MainWindow.xaml.cs

示例5: DeleteDuplicates

        /// <summary>
        /// Slett selgerkoder som ligger dobbelt
        /// </summary>
        /// <returns>Rapport i streng format</returns>
        public string DeleteDuplicates()
        {
            var command = new SqlCeCommand("SELECT * FROM tblSelgerkoder WHERE Avdeling = '" + main.appConfig.Avdeling + "'", main.connection);
            var dt = main.database.GetSqlDataTable("SELECT * FROM tblSelgerkoder WHERE Avdeling = '" + main.appConfig.Avdeling + "'");

            int result = 0; bool TeknikerAlle = false; string returnMsg = "";
            object r = dt.Compute("Count(Selgerkode)", "[Provisjon] = 'TeknikerAlle'");
                if (!DBNull.Value.Equals(r))
            result = Convert.ToInt32(r);
                else
            result = 0;
            if (result > 0)
                TeknikerAlle = true;

            var da = new SqlCeDataAdapter(command);
            var ds = new DataSet();
            da.Fill(ds, "tblSelgerkoder");
            var ca = new SqlCeCommandBuilder(da);

            bool slettTeknikerAlle = false;
            for (int i = 0; i < ds.Tables["tblSelgerkoder"].Rows.Count; i++)
            {
                try
                {
                    string selger = ds.Tables["tblSelgerkoder"].Rows[i]["Provisjon"].ToString().Trim();
                    if (selger.Length > 0)
                        ds.Tables["tblSelgerkoder"].Rows[i]["Provisjon"] = selger;
                }
                catch { }

                provisjon = ds.Tables["tblSelgerkoder"].Rows[i]["Provisjon"].ToString();
                navn = ds.Tables["tblSelgerkoder"].Rows[i]["Selgerkode"].ToString();
                kategori = ds.Tables["tblSelgerkoder"].Rows[i]["Kategori"].ToString();

                if (TeknikerAlle && provisjon == "TeknikerAlle")
                {
                    slettTeknikerAlle = true;
                    continue;
                }

                result = 0;
                r = dt.Compute("Count(Selgerkode)", "[Selgerkode] = '" + navn + "'");
                if (!DBNull.Value.Equals(r))
                    result = Convert.ToInt32(r);
                else
                    result = 0;

                if (result > 1)
                {
                    returnMsg = "Selgerkoder: Fant duplikat. Slettet selgerkode " + navn + " med provisjon " + provisjon;
                    ds.Tables["tblSelgerkoder"].Rows[i].Delete();
                    break;
                }

                if (TeknikerAlle && provisjon == "Tekniker")
                {
                    returnMsg = "Selgerkoder: Med TeknikerAlle valgt på en selgerkode, kan ikke andre motta tekniker-provisjon. Slettet selgerkode " + navn + " med provisjon " + provisjon;
                    ds.Tables["tblSelgerkoder"].Rows[i].Delete();
                    break;
                }
                if (TeknikerAlle && provisjon == "TeknikerAlle" && slettTeknikerAlle)
                {
                    returnMsg = "Selgerkoder: Fant duplikat av TeknikerAlle provisjon. Bare en selgerkode kan motta tekniker-provisjon på alle salg. Slettet selgerkode " + navn + " med provisjon " + provisjon;
                    ds.Tables["tblSelgerkoder"].Rows[i].Delete();
                    break;
                }
            }

            da.Update(ds, "tblSelgerkoder");

            return returnMsg;
        }
开发者ID:tborgund,项目名称:kgsa,代码行数:76,代码来源:Selgerkoder.cs

示例6: TestRowState


//.........这里部分代码省略.........
			}
			#endregion

			#region "是否测试修改, 更改, 删除后的 DataRow.RowState 转化?"
			if (this.tracer.WaitInputAChar("是否测试修改, 更改, 删除后的 DataRow.RowState 转化?") == 'y')
			{

				try
				{

					using (DataSet dataSet = new DataSet())
					{
						/*
						 * Test.sdf 始终复制到 bin 目录下
						 * */
						SqlCeDataAdapter adapter = new SqlCeDataAdapter("select * from Student", @"Data Source=|DataDirectory|\Test.sdf");

						try
						{
							adapter.Fill(dataSet);
							this.tracer.WriteLine("从本地 Test.sdf 数据库填充数据集");

							this.tracer.WriteLine(string.Format("表 Student 第 1 条记录的状态为: {0}", dataSet.Tables[0].Rows[0].RowState));

							int age = Convert.ToInt32(dataSet.Tables[0].Rows[0]["Age"]);

							dataSet.Tables[0].Rows[0]["Age"] = 22;
							this.tracer.WriteLine(string.Format("修改表 Student 第 1 条记录的年龄后, 状态为: {0}", dataSet.Tables[0].Rows[0].RowState));

							dataSet.Tables[0].Rows[0]["Age"] = age;
							this.tracer.WriteLine(string.Format("修改表 Student 第 1 条记录的年龄为原值后, 状态为: {0}", dataSet.Tables[0].Rows[0].RowState));

							SqlCeCommandBuilder builder = new SqlCeCommandBuilder(adapter);
							adapter.UpdateCommand = builder.GetUpdateCommand();
							adapter.Update(dataSet);
							this.tracer.WriteLine("将数据集的修改更新到本地 Test.sdf 数据库");

							this.tracer.WriteLine(string.Format("表 Student 第 1 条记录的状态为: {0}", dataSet.Tables[0].Rows[0].RowState));
						}
						catch (Exception err)
						{ this.tracer.WriteLine(string.Format("异常: {0}", err.Message)); }

					}


					using (DataSet dataSet = new DataSet())
					{
						dataSet.Tables.Add("Student");
						dataSet.Tables["Student"].Columns.AddRange(
							new DataColumn[] {
								new DataColumn("Name", typeof(string)),
								new DataColumn("Age", typeof(int))
							}
							);

						this.tracer.WriteLine("创建表 Student(Name, Age) 到数据集");

						dataSet.Tables["Student"].Rows.Add("小明", "11");
						this.tracer.WriteLine("向表 Student 添加数据");

						this.tracer.WriteLine(string.Format("表 Student 第 1 条记录的状态为: {0}", dataSet.Tables["Student"].Rows[0].RowState));

						dataSet.Tables["Student"].Rows[0]["Age"] = 22;
						this.tracer.WriteLine(string.Format("修改表 Student 第 1 条记录的年龄后, 状态为: {0}", dataSet.Tables["Student"].Rows[0].RowState));

						dataSet.Tables["Student"].Rows[0]["Name"] = "jack";
开发者ID:cform-dev,项目名称:zsharedcode,代码行数:67,代码来源:TestDataSet.RowState.cs

示例7: GetMembersByPlan

        ///// <summary>
        ///// gets the member's name by specified id
        ///// </summary>
        ///// <param name="name"></param>
        ///// <returns>member name</returns>
        //public static int GetMemberIdByName(string name)
        //{
        //    int id = 0;
        //    string query = "SELECT Id FROM Members WHERE LastName = @lname";
        //    using (SqlCeConnection con = DB.GetSqlCeConnection())
        //    {
        //        SqlCeCommand cmd = new SqlCeCommand(query, con);
        //        cmd.Parameters.AddWithValue("@lname", name);
        //        SqlCeDataReader reader = cmd.ExecuteReader();
        //        while (reader.Read())
        //        {
        //            id = reader.GetInt32(0);
        //        }
        //    }
        //    return id;
        //}
        /// <summary>
        /// retrieves all members who have been assigned to the specified plan
        /// </summary>
        /// <returns></returns>
        public static DataTable GetMembersByPlan( int plan_id )
        {
            DataTable dataset;
            using (SqlCeConnection con = DB.GetSqlCeConnection())
            {
                String sql = "SELECT DISTINCT " +
                             "Members.Id, Members.CardNumber, Members.LastName, Members.FirstName, Members.HomePhone, Members.CellPhone, Members.Email, " +
                             "Trainers.FirstName + ' ' + Trainers.LastName AS PersonalTrainer " +
                             "FROM            Memberships INNER JOIN " +
                             "Members ON Memberships.Member = Members.Id " +
                             "LEFT OUTER JOIN "+
                             "Trainers ON Members.PersonalTrainer = Trainers.Id " +
                             "WHERE        (Memberships.[Plan] = @plan_id) ";

                SqlCeCommand cmd = new SqlCeCommand(sql, con);
                cmd.Parameters.AddWithValue("@plan_id", plan_id);

                SqlCeDataAdapter sda = new SqlCeDataAdapter();
                sda.SelectCommand = cmd;

                dataset = new DataTable();
                sda.Fill(dataset);

                sda.Update(dataset);
                return dataset;
            }
        }
开发者ID:rajeshwarn,项目名称:GymManagerPro,代码行数:52,代码来源:Member.cs

示例8: FillData

        public void FillData()
        {
            try
            {
                using (SqlCeConnection con = new SqlCeConnection(conString))
                {
                    con.Open();
                    using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT * FROM table1", con))
                    {

                        DataTable t = new DataTable();
                        a.Fill(t);
                        dataGridView1.DataSource = t;
                        a.Update(t);
                    }
                    con.Close();
                }
                MainWindow m = new MainWindow();
                ((DataTable)this.dataGridView1.DataSource).DefaultView.RowFilter = "Equip =" + "'" + m.TS3 + "'";
              //  ((DataTable)this.dataGridView1.DataSource).DefaultView.RowFilter = "Equip =" + "'" + m.toolStripStatusLabel3.Text.ToString() + "'";
                //   ((DataTable)this.dataGridView1.DataSource).DefaultView.RowFilter = "Equip =" + "'" + textBox13.Text.ToString() + "'";
            }
            catch (Exception ex)
            {
                MainWindow m = new MainWindow();
              m.Log("FillData Error" + ex.ToString());
            }
        }
开发者ID:ksipp01,项目名称:sfVer7_git,代码行数:28,代码来源:Data.cs

示例9: ImportAllCsv


//.........这里部分代码省略.........
                                    bgWorkerImport.ReportProgress(0, "Slettet " + result + " transaksjoner.");

                                command = new SqlCeCommand("SELECT * FROM tblSalg;", con);
                                var da = new SqlCeDataAdapter(command);

                                ds = new DataSet();
                                da.Fill(ds, "tblSalg");
                                var ca = new SqlCeCommandBuilder(da);

                                Message("Prosesserer " + resCSV.Length.ToString("#,##0") + " transaksjoner..");

                                for (int i = 0; i < resCSV.Length; i++)
                                {
                                    // Ta bare med antall ulik 0
                                    if (resCSV[i].Antall != 0 && !resCSV[i].Kgm.Contains("99999") && appConfig.importAll
                                        ||
                                        (resCSV[i].Antall != 0
                                        &&
                                        (resCSV[i].Kgm.StartsWith("531") || resCSV[i].Kgm.StartsWith("533") ||
                                            resCSV[i].Kgm.StartsWith("580") || resCSV[i].Kgm.StartsWith("534") ||
                                            resCSV[i].Kgm.StartsWith("280") || resCSV[i].Kgm.StartsWith("224") ||
                                            resCSV[i].Kgm.StartsWith("480") || resCSV[i].Kgm.StartsWith("431"))
                                        && !appConfig.importAll)
                                        )
                                    {
                                        // dRow[?]
                                        // 0 = SalgID
                                        // 1 = Selgerkode
                                        // 2 = Varegruppe
                                        // 3 = Varekode
                                        // 4 = Dato
                                        // 5 = Antall
                                        DataRow dRow = ds.Tables["tblSalg"].NewRow();
                                        dRow[1] = resCSV[i].Sk; // Selgerkode
                                        if (!appConfig.importAll)
                                        {
                                            if (resCSV[i].Kgm.StartsWith("531")) // desktops
                                                dRow[2] = 531;
                                            if (resCSV[i].Kgm.StartsWith("533")) // laptops
                                                dRow[2] = 533;
                                            if (resCSV[i].Kgm.StartsWith("534")) // nettbrett
                                                dRow[2] = 534;
                                            if (resCSV[i].Kgm.StartsWith("580")) // tjenester
                                                dRow[2] = 580;
                                            if (resCSV[i].Kgm.StartsWith("280")) // nettbrett
                                                dRow[2] = 280;
                                            if (resCSV[i].Kgm.StartsWith("224")) // tjenester
                                                dRow[2] = 224;
                                            if (resCSV[i].Kgm.StartsWith("480")) // nettbrett
                                                dRow[2] = 480;
                                            if (resCSV[i].Kgm.StartsWith("431")) // tjenester
                                                dRow[2] = 431;
                                        }
                                        else
                                        {
                                            dRow[2] = resCSV[i].Kgm.Substring(0, 3); // Ta med alle kategorier.
                                        }
                                        dRow[3] = resCSV[i].Varenummer;
                                        string varDato = resCSV[i].Dato.ToString();
                                        dRow[4] = Convert.ToDateTime(varDato);
                                        dRow[5] = resCSV[i].Antall;
                                        dRow[6] = resCSV[i].Btokr;
                                        dRow[7] = resCSV[i].Avd;
                                        dRow[8] = resCSV[i].Salgspris;
                                        dRow[9] = resCSV[i].BilagsNr;
                                        ds.Tables["tblSalg"].Rows.Add(dRow);
                                    }
                                }

                                // Send data til SQL server og avslutt forbindelsen
                                da.Update(ds, "tblSalg");
                                con.Close();
                                Message("Importering fullført!");
                            }
                            else
                            {
                                Message("Import feil: Fant ingen gyldige transaksjoner.");
                            }
                        }
                        else
                        {
                            Message("Import feil: Ingen transaksjoner funnet! Kontroller om eksportering er korrekt eller sjekk innstillinger.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Message("Import feil: Unntak ved prosessering av transaksjoner. Feilmelding: " + ex.ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Feil ved lesing av CSV.\n" + ex.ToString(), "KGSA - Importering avbrutt", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Message("Import feil: Unntak ved lesing av CSV: " + ex.ToString());
                }
            }
            catch (Exception ex)
            {
                Message("Import feil: Ukjent feil ved imprtering. (" + fileToImport + ") Feilmelding: " + ex.ToString());
            }
        }
开发者ID:tborgund,项目名称:kgsa,代码行数:101,代码来源:ImportClass.cs

示例10: FillData

        void FillData()
        {
            try
            {
                using (SqlCeConnection con = new SqlCeConnection(conString))
                {
                    con.Open();
                    using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT * FROM table1", con))
                    {

                        DataTable t = new DataTable();
                        a.Fill(t);
                        dataGridView1.DataSource = t;
                        a.Update(t);

                        //    FileLog2(GetCreateFromDataTableSQL("table1", t)); //ytry to create the create string from here 7-25-14

                    }
                    con.Close();
                }
                ((DataTable)this.dataGridView1.DataSource).DefaultView.RowFilter = "Equip =" + "'" + toolStripStatusLabel3.Text.ToString() + "'";
                //   ((DataTable)this.dataGridView1.DataSource).DefaultView.RowFilter = "Equip =" + "'" + textBox13.Text.ToString() + "'";
            }
            catch (Exception ex)
            {
                Log("FillData Error" + ex.ToString());
            }
        }
开发者ID:ksipp01,项目名称:sfVer7_git,代码行数:28,代码来源:ScopeFocus_Arduino_ver6_ascomFocus_addBkgndCapture_AddASCOMFIlter.cs

示例11: AddFolderToDB

 private static void AddFolderToDB(object folder_param)
 {
     string folderPath = ((folder_params)folder_param).folderpath;
     using (SqlCeConnection con = CreateConnection(((folder_params)folder_param).filepath))
     {
         con.Open();
         string sql = "SELECT Count(*) FROM Folders WHERE name='" +
             folderPath.Replace("'", "`") + "'";
         SqlCeCommand com = new SqlCeCommand(sql, con);
         if (Convert.ToInt32(com.ExecuteScalar()) != 0)
         {
             return;
         }
         SqlCeDataAdapter da = new SqlCeDataAdapter("Select * FROM Folders", con);
         da.InsertCommand = new SqlCeCommand(
             "INSERT INTO Folders (name) values(@folder_name)");
         da.InsertCommand.Parameters.Add("@folder_name", SqlDbType.NVarChar, 255, "name");
         da.InsertCommand.Connection = con;
         DataSet ds = new DataSet("Folder");
         DataTable dt = new DataTable("Folders");
         dt.Columns.Add(new DataColumn("id", typeof(int)));
         dt.Columns.Add(new DataColumn("name", typeof(string)));
         ds.Tables.Add(dt);
         da.Fill(ds, "Folders");
         DataRow drAdd = dt.NewRow();
         int RowCount = ds.Tables["Folders"].Rows.Count - 1;
         if (RowCount >= 0)
         {
             drAdd["id"] = int.Parse(ds.Tables["Folders"].Rows[RowCount]["id"].ToString()) + 1;
         }
         else
         {
             drAdd["id"] = 1;
         }
         drAdd["name"] = folderPath.Replace("'", "`");
         dt.Rows.Add(drAdd);
         da.Update(ds, "Folders");
     }
 }
开发者ID:kostyakozko,项目名称:myplayer,代码行数:39,代码来源:FolderProcessing.cs

示例12: saveFileDialog1_FileOk

            private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
            {
                //if (ExcelFilename == null)
                //{
                // //   DialogResult result = saveFileDialog1.ShowDialog();
                    ExcelFilename = saveFileDialog1.FileName.ToString();
                    textBox33.Text = ExcelFilename.ToString();
                //}
                using (SqlCeConnection con = new SqlCeConnection(conString))
                {
                    con.Open();
                    using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT * FROM table1", con))
                    {
                        DataTable t = new DataTable();
                        a.Fill(t);
                        // dataGridView1.DataSource = t;
                        a.Update(t);
                        object missing = System.Reflection.Missing.Value;
                        if (ExcelFilename.IndexOf(@".") == 0)//if extension not on filename
                        {
                            MessageBox.Show("Filename extension not selected, must select text or Excel file.  Export Aborted", "scopefocus");
                            return;
                        }

                        if (Path.GetExtension(ExcelFilename.Substring(1)) == ".txt" || Path.GetExtension(ExcelFilename.Substring(1)) == ".TXT")
                            TextCSV_FromDataTable(t, ExcelFilename);
                        else
                            Excel_FromDataTable(t);

                    }
                    con.Close();
                  //  textBox33.Text = ExcelFilename.ToString();
                }
            }
开发者ID:ksipp01,项目名称:sfVer7_git,代码行数:34,代码来源:ScopeFocus_Arduino_ver6_ascomFocus_addBkgndCapture_AddASCOMFIlter.cs

示例13: button17_Click

        //View All button
        private void button17_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlCeConnection con = new SqlCeConnection(conString))
                {
                    con.Open();
                    using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT * FROM table1", con))
                    {

                        DataTable t = new DataTable();
                        a.Fill(t);
                        dataGridView1.DataSource = t;
                        a.Update(t);
                    }
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                Log("View All SQL data Error" + ex.ToString());
            }
        }
开发者ID:ksipp01,项目名称:sfVer7_git,代码行数:24,代码来源:ScopeFocus_Arduino_ver6_ascomFocus_addBkgndCapture_AddASCOMFIlter.cs

示例14: UpdateBudgetSelgerkoder

        public void UpdateBudgetSelgerkoder(int budgetId)
        {
            try
            {
                var currentBudgetInfo = GetBudgetInfo(budgetId);

                if (currentBudgetInfo != null)
                {
                    var sk = main.salesCodes.GetBudgetSelgerkoder(currentBudgetInfo.kategori);

                    var command = new SqlCeCommand("SELECT * FROM tblBudgetSelger WHERE BudgetId = " + budgetId, main.connection);
                    var da = new SqlCeDataAdapter(command);
                    var ds = new DataSet();
                    da.Fill(ds, "tblBudgetSelger");
                    var ca = new SqlCeCommandBuilder(da);
                    foreach (string selger in sk)
                    {
                        var foundAuthors = ds.Tables["tblBudgetSelger"].Select("Selgerkode = '" + selger + "'");
                        if (foundAuthors.Length == 0)
                        {
                            DataRow dRow = ds.Tables["tblBudgetSelger"].NewRow();
                            dRow["BudgetId"] = budgetId;
                            dRow["Selgerkode"] = selger;
                            dRow["Timer"] = 0;
                            dRow["Dager"] = 0;
                            dRow["Multiplikator"] = 1;
                            dRow["Comment"] = "";
                            ds.Tables["tblBudgetSelger"].Rows.Add(dRow);
                        }
                    }
                    da.Update(ds, "tblBudgetSelger");

                    command = new SqlCeCommand("SELECT * FROM tblBudgetTimer WHERE BudgetId = " + budgetId, main.connection);
                    da = new SqlCeDataAdapter(command);
                    ds = new DataSet();
                    da.Fill(ds, "tblBudgetTimer");
                    ca = new SqlCeCommandBuilder(da);
                    foreach (string selger in sk)
                    {
                        var foundAuthors = ds.Tables["tblBudgetTimer"].Select("Selgerkode = '" + selger + "'");
                        if (foundAuthors.Length == 0)
                        {
                            DataRow dRow = ds.Tables["tblBudgetTimer"].NewRow();
                            dRow["BudgetId"] = budgetId;
                            dRow["Selgerkode"] = selger;
                            ds.Tables["tblBudgetTimer"].Rows.Add(dRow);
                        }
                    }
                    da.Update(ds, "tblBudgetTimer");
                }
            }
            catch(Exception ex)
            {
                Log.Unhandled(ex);
            }
        }
开发者ID:tborgund,项目名称:kgsa,代码行数:56,代码来源:Budget.cs

示例15: SumWorkHoursAndDays

        public void SumWorkHoursAndDays(BudgetInfo budget_info)
        {
            try
            {
                var con = new SqlCeConnection(FormMain.SqlConStr);
                con.Open();
                var command = new SqlCeCommand("SELECT * FROM tblBudgetSelger WHERE BudgetId = " + budget_info.budget_id, con);
                var da = new SqlCeDataAdapter(command);
                var ds = new DataSet();
                da.Fill(ds, "tblBudgetTimer");
                var ca = new SqlCeCommandBuilder(da);

                DataTable dtTimer = main.database.GetSqlDataTable("SELECT * FROM tblBudgetTimer WHERE BudgetId = " + budget_info.budget_id);

                if (dtTimer.Rows.Count == 0)
                    return;

                for (int i = 0; i < dtTimer.Rows.Count; i++)
                {
                    for (int b = 0; b < ds.Tables["tblBudgetTimer"].Rows.Count; b++)
                    {
                        if (ds.Tables["tblBudgetTimer"].Rows[b]["Selgerkode"].ToString() == dtTimer.Rows[i]["Selgerkode"].ToString())
                        {
                            decimal timer = 0, dager = 0;

                            for (int c = 3; c < dtTimer.Columns.Count; c++)
                            {
                                if (!DBNull.Value.Equals(dtTimer.Rows[i][c]))
                                {
                                    decimal t = Convert.ToDecimal(dtTimer.Rows[i][c]);
                                    timer += t;
                                    dager++;
                                }
                            }

                            ds.Tables["tblBudgetTimer"].Rows[b]["Timer"] = timer;
                            ds.Tables["tblBudgetTimer"].Rows[b]["Dager"] = dager;

                        }
                    }
                }

                da.Update(ds, "tblBudgetTimer");

                // Oppdater timeantall oppdaterings tid
                con = new SqlCeConnection(FormMain.SqlConStr);
                con.Open();
                command = new SqlCeCommand("SELECT * FROM tblBudget WHERE Id = " + budget_info.budget_id, con);
                da = new SqlCeDataAdapter(command);
                ds = new DataSet();
                da.Fill(ds, "tblBudget");
                ca = new SqlCeCommandBuilder(da);
                if (ds.Tables["tblBudget"].Rows.Count > 0)
                    ds.Tables["tblBudget"].Rows[0]["Updated"] = DateTime.Now;
                else
                    Log.n("Fikk ikke satt tidspunkt for timeantall oppdatering.", Color.Red);
                da.Update(ds, "tblBudget");

                con.Close();
                con.Dispose();
            }
            catch(Exception ex)
            {
                Log.Unhandled(ex);
            }
        }
开发者ID:tborgund,项目名称:kgsa,代码行数:66,代码来源:Budget.cs


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