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

<legend id='ruF3M'><style id='ruF3M'><dir id='ruF3M'><q id='ruF3M'></q></dir></style></legend>
    <bdo id='ruF3M'></bdo><ul id='ruF3M'></ul>

  • <i id='ruF3M'><tr id='ruF3M'><dt id='ruF3M'><q id='ruF3M'><span id='ruF3M'><b id='ruF3M'><form id='ruF3M'><ins id='ruF3M'></ins><ul id='ruF3M'></ul><sub id='ruF3M'></sub></form><legend id='ruF3M'></legend><bdo id='ruF3M'><pre id='ruF3M'><center id='ruF3M'></center></pre></bdo></b><th id='ruF3M'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ruF3M'><tfoot id='ruF3M'></tfoot><dl id='ruF3M'><fieldset id='ruF3M'></fieldset></dl></div>
  • <small id='ruF3M'></small><noframes id='ruF3M'>

    <tfoot id='ruF3M'></tfoot>

        為什么會出現“數據類型轉換錯誤"?使用 Ex

        Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
            • <bdo id='0MGmz'></bdo><ul id='0MGmz'></ul>
              <i id='0MGmz'><tr id='0MGmz'><dt id='0MGmz'><q id='0MGmz'><span id='0MGmz'><b id='0MGmz'><form id='0MGmz'><ins id='0MGmz'></ins><ul id='0MGmz'></ul><sub id='0MGmz'></sub></form><legend id='0MGmz'></legend><bdo id='0MGmz'><pre id='0MGmz'><center id='0MGmz'></center></pre></bdo></b><th id='0MGmz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0MGmz'><tfoot id='0MGmz'></tfoot><dl id='0MGmz'><fieldset id='0MGmz'></fieldset></dl></div>

                1. <small id='0MGmz'></small><noframes id='0MGmz'>

                2. <tfoot id='0MGmz'></tfoot>

                    <tbody id='0MGmz'></tbody>
                  <legend id='0MGmz'><style id='0MGmz'><dir id='0MGmz'><q id='0MGmz'></q></dir></style></legend>
                  本文介紹了為什么會出現“數據類型轉換錯誤"?使用 ExecuteNonQuery()?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  為什么我在運行此代碼時會出現將 varchar 轉換為浮點數的錯誤?

                  Why do I get an error converting varchar into float conversion when I run this code?

                  我不明白,請幫忙.

                  Imports System.Data.SqlClient
                  
                  Public Class Form1
                      Dim selected As Double
                      Dim HourItem As Double
                      Dim OverTimeRate As Double
                      Dim connection As New SqlConnection("Data Source=DESKTOP-F55AVQ6\SQLEXPRESS;Initial Catalog=Db_Suncrest_Financial;Integrated Security=True")
                  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                      'TODO: This line of code loads data into the 'Db_Suncrest_FinancialDataSet.Tb_Suncrest_Financial_Payroll' table. You can move, or remove it, as needed.
                      Me.Tb_Suncrest_Financial_PayrollTableAdapter.Fill(Me.Db_Suncrest_FinancialDataSet.Tb_Suncrest_Financial_Payroll)
                  
                  End Sub
                  
                  Private Sub Employee_PositionComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Employee_PositionComboBox.SelectedIndexChanged
                      Select Case Employee_PositionComboBox.SelectedItem
                          Case "Banker"
                              selected = 14.75
                          Case "Bank Teller"
                              selected = 10
                          Case "Loan Processor"
                              selected = 17.1
                          Case "Mortgage Consultant"
                              selected = 19.22
                          Case "Investment Representative"
                              selected = 19.31
                          Case "Credit Analyst"
                              selected = 19.88
                          Case "Investment Banker"
                              selected = 22.75
                          Case "Relationship Manager"
                              selected = 23.85
                          Case "Financial Adviser"
                              selected = 23.99
                          Case "Financial Analyst"
                              selected = 25.84
                          Case "Asset Manager"
                              selected = 26.86
                          Case "Under Writer"
                              selected = 27.56
                          Case "Internal Auditor"
                              selected = 28.79
                          Case "Investment Banking Analyst"
                              selected = 39.37
                          Case "Loan Officer"
                              selected = 43.18
                      End Select
                  
                      Rate_Per_HourTextBox.Text = selected
                  End Sub
                  
                  Private Sub Hours_WorkedComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Hours_WorkedComboBox.SelectedIndexChanged
                      Select Case Hours_WorkedComboBox.SelectedItem
                          Case "8"
                              HourItem = 8
                          Case "7"
                              HourItem = 7
                          Case "6"
                              HourItem = 6
                          Case "5"
                              HourItem = 5
                          Case "4"
                              HourItem = 4
                      End Select
                  End Sub
                  
                  Private Sub OverTime_RateComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles OverTime_RateComboBox.SelectedIndexChanged
                      Select Case OverTime_RateComboBox.SelectedItem
                          Case "Normal Day"
                              OverTimeRate = 1.25
                          Case "Rest Day"
                              OverTimeRate = 1.69
                          Case "Special Non-Working Hoiday"
                              OverTimeRate = 1.69
                          Case "Special Non-Working Hoiday + Rest Day"
                              OverTimeRate = 1.95
                          Case "Regular Holliday"
                              OverTimeRate = 2.6
                          Case "Regular Holliday + Rest Day"
                              OverTimeRate = 3.38
                      End Select
                  End Sub
                  
                  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                      Basic_PayTextBox.Text = HourItem * selected * 30
                      OverTime_PayTextBox.Text = OverTimeRate * selected * OverTime_HoursTextBox.Text
                      Gross_SalaryTextBox.Text = OverTime_PayTextBox.Text + Basic_PayTextBox.Text
                  
                  
                  
                      Total_Salary_W_TaxTextBox.Text = Gross_SalaryTextBox.Text * (0.0034 + 0.0363 + 0.01375)
                  
                      Date_TimeTextBox.Text = Format(Now, "General Date")
                  
                  
                  End Sub
                  
                  Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
                  
                      connection.Open()
                      Dim command As New SqlCommand("Insert into Tb_Suncrest_Financial_Payroll(Employee_Id_No, Employee_Name, Employee_Position, Residence, Date_Time, Hours_Worked, Rate_Per_Hour, 
                                                     Basic_Pay, OverTime_Hours, OverTime_Rate, OverTime_Pay, Gross_Salary, SSS, Pagibig, Philhealth, Total_Salary_W_Tax) 
                                                     Values(
                                                     '" & Employee_Id_NoTextBox.Text & "', '" & Employee_NameTextBox.Text & "', '" & Employee_PositionComboBox.Text & "', '" & ResidenceTextBox.Text & "', '" & Date_TimeTextBox.Text & "',
                                                     '" & Hours_WorkedComboBox.Text & "', '" & Rate_Per_HourTextBox.Text & "', '" & Basic_PayTextBox.Text & "', '" & OverTime_HoursTextBox.Text & "', '" & OverTime_RateComboBox.Text & "',
                                                     '" & OverTime_PayTextBox.Text & "', '" & Gross_SalaryTextBox.Text & "', '" & SSSTextBox.Text & "', '" & PagibigTextBox.Text & "', '" & PhilhealthTextBox.Text & "', '" & Total_Salary_W_TaxTextBox.Text & "')", connection)
                  
                  
                  
                      command.Parameters.AddWithValue("@Employee_Id_No", SqlDbType.Int)
                      command.Parameters.AddWithValue("@Employee_Name", SqlDbType.VarChar)
                      command.Parameters.AddWithValue("@Employee_Position", SqlDbType.VarChar)
                      command.Parameters.AddWithValue("@Residence", SqlDbType.VarChar)
                      command.Parameters.AddWithValue("@Date_Time", SqlDbType.DateTime)
                      command.Parameters.AddWithValue("@Hours_Worked", SqlDbType.Int)
                      command.Parameters.AddWithValue("@Rate_Per_Hour", SqlDbType.Float)
                      command.Parameters.AddWithValue("@Basic_Pay", SqlDbType.Float)
                      command.Parameters.AddWithValue("@OverTime_Hours", SqlDbType.Float)
                      command.Parameters.AddWithValue("@OverTime_Rate", SqlDbType.Float)
                      command.Parameters.AddWithValue("@OverTime_Pay", SqlDbType.Float)
                      command.Parameters.AddWithValue("@Gross_Salary", SqlDbType.Float)
                      command.Parameters.AddWithValue("@SSS", SqlDbType.Float)
                      command.Parameters.AddWithValue("@Pagibig", SqlDbType.Float)
                      command.Parameters.AddWithValue("@Philhealth", SqlDbType.Float)
                      command.Parameters.AddWithValue("@Total_Salary_W_Tax", SqlDbType.Float)
                  
                  
                      If command.ExecuteNonQuery() = 1 Then
                          MessageBox.Show("Added")
                      Else
                          MessageBox.Show("Not Added")
                      End If
                      connection.Close()
                  End Sub
                  
                  End Class
                  

                  推薦答案

                  以下是@Charlieface 出色回答提出的想法的示例.

                  Here is an example of the ideas presented by @Charlieface excellent answer.

                  另外幾點.

                  ID 字段是身份字段是很常見的(自動編號) 檢查您的數據庫.如果是這種情況,那么您將不會在字段列表中包含 Employee_ID,值列表將任何內容添加到該字段的參數集合中.在您的情況下,這似乎是一個工資表,因此 Employee_ID 可能是其他地方員工表的外鍵.在這種情況下,代碼沒問題.

                  It is very common for ID fields to be identity fields (auto-number) Check your database. If this is the case then you would not include Employee_ID in the fields list, Values list of add anything to the parameters collection for that field. In your case this appears to be a payroll table so perhaps Employee_ID is a foreign key to an employees table elsewhere. In this case, the code is fine.

                  用戶很容易輸入任何TextBox.我強烈建議您在嘗試插入之前使用 .TryParse 驗證數字和日期的所有輸入.

                  Users are apt to enter anything is a TextBox. I strongly suggest that you validate all the input for numbers and dates with .TryParse before attempting the insert.

                  不要在連接打開時顯示消息框.連接是寶貴的資源,應該在 .Execute... 之前直接打開,并通過 End Using 盡快關閉.

                  Never present a message box while a connection is open. Connections are precious resources and should be opened directly before the .Execute... and closed as soon as possible with End Using.

                  似乎有幾個計算字段根本不需要存儲,但存儲很便宜,而且可能會使其他查詢更簡單.

                  There appears to be several calculated fields that do not need to be stored at all but storage is cheap and it will probably make other queries simpler.

                  Private ConStr As String = "Your connection string"
                  
                  Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
                      Dim RetVal As Integer
                      Dim Sql = "Insert into Tb_Suncrest_Financial_Payroll(Employee_Id_No, Employee_Name, Employee_Position, Residence, Date_Time, Hours_Worked, Rate_Per_Hour, 
                                                 Basic_Pay, OverTime_Hours, OverTime_Rate, OverTime_Pay, Gross_Salary, SSS, 
                                                 Pagibig, Philhealth, Total_Salary_W_Tax) 
                                                 Values(
                                                 @Employee_Id_No, @Employee_Name, @Employee_Position, @Residence, @Hours_Worked,@Rate_Per_Hour, 
                                                 @Basic_PayTextBox, @OverTime_Hours, @OverTime_Rate, @Gross_Salary, @SSS,
                                                 @Pagibig, @Philhealth, @Total_Salary_W_Tax);"
                      Using connection As New SqlConnection(ConStr),
                              command As New SqlCommand(Sql, connection)
                          With command.Parameters
                              .Add("@Employee_Id_No", SqlDbType.Int).Value = CInt(Employee_Id_NoTextBox.Text)
                              .Add("@Employee_Name", SqlDbType.VarChar).Value = Employee_NameTextBox.Text
                              .Add("@Employee_Position", SqlDbType.VarChar).Value = Employee_Position.Text
                              .Add("@Residence", SqlDbType.VarChar).Value = ResidenceTextBox.Text
                              .Add("@Date_Time", SqlDbType.DateTime).Value = CDate(Date_TimeTextBox.Text)
                              .Add("@Hours_Worked", SqlDbType.Int).Value = CInt(Hours_WorkedComboBox.Text)
                              .Add("@Rate_Per_Hour", SqlDbType.Float).Value = CDbl(Rate_Per_HourTextBox.Text)
                              .Add("@Basic_Pay", SqlDbType.Float).Value = CDbl(Basic_PayTextBox.Text)
                              .Add("@OverTime_Hours", SqlDbType.Float).Value = CDbl(OverTime_HoursTextBox.Text)
                              .Add("@OverTime_Rate", SqlDbType.Float).Value = CDbl(OverTime_RateComboBox.Text)
                              .Add("@OverTime_Pay", SqlDbType.Float).Value = CDbl(OverTime_PayTextBox.Text)
                              .Add("@Gross_Salary", SqlDbType.Float).Value = CDbl(Gross_SalaryTextBox.Text)
                              .Add("@SSS", SqlDbType.Float).Value = CDbl(SSSTextBox.Text)
                              .Add("@Pagibig", SqlDbType.Float).Value = CDbl(PagibigTextBox.Text)
                              .Add("@Philhealth", SqlDbType.Float).Value = CDbl(PhilhealthTextBox.Text)
                              .Add("@Total_Salary_W_Tax", SqlDbType.Float).Value = CDbl(Total_Salary_W_TaxTextBox.Text)
                          End With
                          connection.Open()
                          RetVal = command.ExecuteNonQuery
                      End Using
                      If RetVal = 1 Then
                          MessageBox.Show("Added")
                      Else
                          MessageBox.Show("Not Added")
                      End If
                  End Sub
                  

                  這篇關于為什么會出現“數據類型轉換錯誤"?使用 ExecuteNonQuery()?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                  WinForms application design - moving documents from SQL Server to file storage(WinForms 應用程序設計——將文檔從 SQL Server 移動到文件存儲)

                        <tfoot id='AWVJ1'></tfoot>
                          <bdo id='AWVJ1'></bdo><ul id='AWVJ1'></ul>

                          <i id='AWVJ1'><tr id='AWVJ1'><dt id='AWVJ1'><q id='AWVJ1'><span id='AWVJ1'><b id='AWVJ1'><form id='AWVJ1'><ins id='AWVJ1'></ins><ul id='AWVJ1'></ul><sub id='AWVJ1'></sub></form><legend id='AWVJ1'></legend><bdo id='AWVJ1'><pre id='AWVJ1'><center id='AWVJ1'></center></pre></bdo></b><th id='AWVJ1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AWVJ1'><tfoot id='AWVJ1'></tfoot><dl id='AWVJ1'><fieldset id='AWVJ1'></fieldset></dl></div>
                          <legend id='AWVJ1'><style id='AWVJ1'><dir id='AWVJ1'><q id='AWVJ1'></q></dir></style></legend>

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

                              <tbody id='AWVJ1'></tbody>
                            主站蜘蛛池模板: 精品亚洲国产成av人片传媒 | 日韩高清中文字幕 | 欧美激情久久久 | 国产欧美精品一区二区三区 | 91资源在线| 成人在线一级片 | 国产99久久| 91日韩 | 亚洲欧洲成人av每日更新 | 日韩欧美三级电影在线观看 | 成人在线视频观看 | 国产成人网 | 亚洲精品二区 | 羞羞视频在线观免费观看 | 欧美福利精品 | 超碰在线国产 | 日韩一区二区在线视频 | 国产不卡一区 | 精品视频在线免费观看 | 久久久久久久久久影视 | 99久久中文字幕三级久久日本 | 亚洲永久字幕 | a级黄色片视频 | 一级片免费视频 | 国产精品久久久久久久免费大片 | 国产福利91精品一区二区三区 | 91精品国产乱码久久久久久久久 | 成人在线视频网站 | 黄色av免费| 久久久精彩视频 | 久久精品中文字幕 | 噜啊噜在线 | 一级视频在线免费观看 | 日本免费在线 | 国产精品极品美女在线观看免费 | 秋霞a级毛片在线看 | 久久久久一区二区三区四区 | 国产成人自拍一区 | 日韩欧美三区 | 九色国产| 国产美女精品视频免费观看 |