久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <bdo id='QTy09'></bdo><ul id='QTy09'></ul>
    1. <tfoot id='QTy09'></tfoot>
    2. <small id='QTy09'></small><noframes id='QTy09'>

      <i id='QTy09'><tr id='QTy09'><dt id='QTy09'><q id='QTy09'><span id='QTy09'><b id='QTy09'><form id='QTy09'><ins id='QTy09'></ins><ul id='QTy09'></ul><sub id='QTy09'></sub></form><legend id='QTy09'></legend><bdo id='QTy09'><pre id='QTy09'><center id='QTy09'></center></pre></bdo></b><th id='QTy09'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QTy09'><tfoot id='QTy09'></tfoot><dl id='QTy09'><fieldset id='QTy09'></fieldset></dl></div>
        <legend id='QTy09'><style id='QTy09'><dir id='QTy09'><q id='QTy09'></q></dir></style></legend>
      1. 從文本框值插入數字(十進制)數據

        Insert numerical (decimal) data from textbox values(從文本框值插入數字(十進制)數據)
        <legend id='SaeLn'><style id='SaeLn'><dir id='SaeLn'><q id='SaeLn'></q></dir></style></legend>
          <tfoot id='SaeLn'></tfoot>
          <i id='SaeLn'><tr id='SaeLn'><dt id='SaeLn'><q id='SaeLn'><span id='SaeLn'><b id='SaeLn'><form id='SaeLn'><ins id='SaeLn'></ins><ul id='SaeLn'></ul><sub id='SaeLn'></sub></form><legend id='SaeLn'></legend><bdo id='SaeLn'><pre id='SaeLn'><center id='SaeLn'></center></pre></bdo></b><th id='SaeLn'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SaeLn'><tfoot id='SaeLn'></tfoot><dl id='SaeLn'><fieldset id='SaeLn'></fieldset></dl></div>

              <bdo id='SaeLn'></bdo><ul id='SaeLn'></ul>

              <small id='SaeLn'></small><noframes id='SaeLn'>

                  <tbody id='SaeLn'></tbody>
                  本文介紹了從文本框值插入數字(十進制)數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我對以下問題感到困惑;

                  I am confused by the following issue;

                  我有一個 C# (WindowsForms) 應用程序,我連接到 SQL Server 數據庫,并且在我開始使用數字數據之前,插入、選擇、更新都沒有問題;

                  I have a C# (WindowsForms) application which I connect to a SQL Server DB and have no problem to INSERT, SELECT, UPDATE... until I started to work with numerical data;

                  此應用程序的目的是管理員工、他們的合同、工作費率、合同期限、小時費率......并用它來做一些有趣的計算,沒什么魔法.

                  Purpose of this application is to manage employees, their contracts, rate of work, contracts durations, hourly rates... and do some funny calculations with that, nothing magic.

                  基本上,我需要在我的數據庫中存儲一些格式為0000,0000"的值(十進制?雙精度?浮點數?).

                  Basically, I need to store some values (decimal? double? float?) with the format "0000,0000" in my DB.

                  • 在我的數據庫中,我已將我的表設置為我需要將這些000,0000"值設為十進制的所有列

                  • In my DB, I have set my table with all columns where I require these "000,0000" values to decimal

                  在我的表單中,我沒有為我的文本框指定任何特定屬性,

                  In my forms, I haven't specified any specific properties to my textboxes,

                  為了插入,我使用了我定義了十進制參數的方法

                  To insert I use a method for which I defined decimal arguments

                      public void createNewContract(int employeeId, string agency, string role, string contractType, string startDate,
                      string endDate, string lineManager, string reportTo, string costCenter, string functionEng, string atrNo, string atrDate, string prNo, string prDate,
                      string poNo, string poDate, string comments, decimal duration, decimal workRatePercent, string currency, decimal hourlyRate, decimal value)
                  {
                      if (conn.State.ToString() == "Closed")
                      {
                          conn.Open();
                      }
                      SqlCommand newCmd = conn.CreateCommand();
                      newCmd.Connection = conn;
                      newCmd.CommandType = CommandType.Text;
                      newCmd.CommandText = "INSERT INTO tblContracts (CreatedById, CreationDate, EmployeeId, Role, ContractType, StartDate, "
                      + "EndDate, Agency, LineManager, ReportTo, CostCenter, FunctionEng, AtrNo, AtrDate, PrNo, PrDate, PoNo, PoDate, Comments, Duration, WorkRatePercent, Currency, HourlyRate, Value)"
                      + "VALUES ('" + connectedUser.getUserId() + "','" + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss") + "','" + employeeId + "','" + role + "','" + contractType
                      + "','" + startDate + "','" + endDate + "','" + agency + "','" + lineManager + "','" + reportTo + "','" + costCenter + "','" + functionEng + "','" + atrNo + "','" + atrDate + "','" + prNo
                       + "','" + prDate + "','" + poNo + "','" + poDate + "','" + comments + "','" + duration + "','" + workRatePercent + "','" + currency + "','" + hourlyRate + "','" + value + "')";
                      newCmd.ExecuteNonQuery();
                      MessageBox.Show("Contract has been successfully created", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                  }
                  

                  (通過這種方法,我只需要插入00,0000作為持續時間(nb小時),工作率百分比,每小時費率(貨幣貨幣)和價值(貨幣貨幣))

                  (through this method, I only need to insert as 00,0000 a duration (nb hours), workrate percentage, an hourly rate (money in a currency) and a value (money in a currency))

                  • 為了捕獲我的文本框值并通過我的方法createNewContrat"發送它們,我嘗試過Convert.ToDecimal(this.txtDuration.Text) 和許多其他對我來說似乎不錯的東西,但我無法理解機制,我當然沒有使用最實用/最聰明的解決方案......

                  我不斷收到以下錯誤;

                  System.FormatException: Le format de la cha?ne d'entrée est 不正確.= 輸入/輸入字符串的格式不正確
                  à System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
                  à System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
                  à System.Convert.ToDecimal(String value)

                  你會推薦什么?

                  推薦答案

                  首先,在處理SqlConnectionSqlCommandusing> 和所有其他實現 IDisposable 的類只需閱讀更多相關信息..

                  First of all, Always use using when dealing with SqlConnection and SqlCommand and all other classes that implements IDisposable just read more about it..

                  第二件事,始終將參數與 SqlCommand 一起使用,并且永遠不要將值作為字符串傳遞給 sql 字符串.這是一個嚴重的安全問題.除了這些參數之外,還可以讓您的代碼人性化!

                  Second thing, Always use parameters with SqlCommand and never pass the values as a string to the sql string. This is a serious security issue. In addition to that parameters makes your code human friendly!

                  // Always use (using) when dealing with Sql Connections and Commands
                  using (sqlConnection conn = new SqlConnection())
                  {
                      conn.Open();
                  
                      using (SqlCommand newCmd = new SqlCommand(conn))
                      {
                          newCmd.CommandType = CommandType.Text;
                  
                          newCmd.CommandText = 
                                @"INSERT INTO tblContracts (CreatedById, CreationDate, EmployeeId, Role, ContractType, StartDate, EndDate, Agency, LineManager, ReportTo, CostCenter, FunctionEng, AtrNo, AtrDate, PrNo, PrDate, PoNo, PoDate, Comments, Duration, WorkRatePercent, Currency, HourlyRate, Value) 
                                VALUES (@UserID, @CreationDate, @EmployeeID, @Role.....etc)";
                  
                          // for security reasons (Sql Injection attacks) always use parameters
                          newCmd.Parameters.Add("@UserID", SqlDbType.NVarChar, 50)
                               .Value = connectedUser.getUserId();
                  
                          newCmd.Parameters.Add("@CreationDate", SqlDbType.DateTime)
                               .Value = DateTime.Now;
                  
                          // To add a decimal value from TextBox
                          newCmd.Parameters.Add("@SomeValue", SqlDbType.Decimal)
                               .Value = System.Convert.ToDecimal(txtValueTextBox.Text);
                  
                          // complete the rest of the parameters
                          // ........
                  
                          newCmd.ExecuteNonQuery();
                  
                          MessageBox.Show("Contract has been successfully created", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                      }
                  }
                  

                  這篇關于從文本框值插入數字(十進制)數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數調用按鈕 OnClick)

                    <bdo id='6fKSE'></bdo><ul id='6fKSE'></ul>

                    <small id='6fKSE'></small><noframes id='6fKSE'>

                    <tfoot id='6fKSE'></tfoot>
                          <legend id='6fKSE'><style id='6fKSE'><dir id='6fKSE'><q id='6fKSE'></q></dir></style></legend>
                            <tbody id='6fKSE'></tbody>
                            <i id='6fKSE'><tr id='6fKSE'><dt id='6fKSE'><q id='6fKSE'><span id='6fKSE'><b id='6fKSE'><form id='6fKSE'><ins id='6fKSE'></ins><ul id='6fKSE'></ul><sub id='6fKSE'></sub></form><legend id='6fKSE'></legend><bdo id='6fKSE'><pre id='6fKSE'><center id='6fKSE'></center></pre></bdo></b><th id='6fKSE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6fKSE'><tfoot id='6fKSE'></tfoot><dl id='6fKSE'><fieldset id='6fKSE'></fieldset></dl></div>
                            主站蜘蛛池模板: 亚洲欧美日韩电影 | 男女视频免费 | 国产精品欧美一区二区三区不卡 | 日韩综合一区 | 亚洲一区免费在线 | 日韩成人在线一区 | 99re在线视频 | 国产二区三区 | 一区二区三区中文字幕 | 午夜视频网站 | 2020国产在线 | 日本成人二区 | 日本不卡在线视频 | 91国产精品 | 精品国产91乱码一区二区三区 | 中文字幕精品视频在线观看 | 国产精品久久久久久吹潮日韩动画 | 国产精品国产精品 | 精品1区 | 午夜ww| 国产一区久久 | 欧美亚洲国语精品一区二区 | 91免费入口| 婷婷久| 午夜爱爱毛片xxxx视频免费看 | 亚洲一区二区三区国产 | 日韩一区中文字幕 | 日本黄色激情视频 | 欧美一区二区三区四区视频 | 一级毛片在线播放 | 欧美一级久久 | 婷婷在线视频 | 狠狠操狠狠干 | 午夜国产 | www.三级| 久久一区二区三区四区 | 日韩精品中文字幕在线 | 亚洲欧洲中文 | www.日本在线观看 | 一区二区免费视频 | 色综合99|