pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<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="iaiye2k" 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="mwoy0ae" 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="msscaia" 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>
                            主站蜘蛛池模板: 原色会计-合肥注册公司_合肥代理记账公司_营业执照代办 | 智能垃圾箱|垃圾房|垃圾分类亭|垃圾分类箱专业生产厂家定做-宿迁市传宇环保设备有限公司 | 99文库_实习生实用的范文资料文库站 | 帽子厂家_帽子工厂_帽子定做_义乌帽厂_帽厂_制帽厂 | 蒸压釜_蒸养釜_蒸压釜厂家-山东鑫泰鑫智能装备有限公司 | 电主轴-高速精密电主轴-高速电机厂家-瑞德沃斯品牌有限公司 | RO反渗透设备_厂家_价格_河南郑州江宇环保科技有限公司 | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 加中寰球移民官网-美国移民公司,移民机构,移民中介,移民咨询,投资移民 | 汽车润滑油厂家-机油/润滑油代理-高性能机油-领驰慧润滑科技(河北)有限公司 | 洗地机-全自动/手推式洗地机-扫地车厂家_扬子清洁设备 | 无锡市珂妮日用化妆品有限公司|珂妮日化官网|洗手液厂家 | EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 带压开孔_带压堵漏_带压封堵-菏泽金升管道工程有限公司 | 陶氏道康宁消泡剂_瓦克消泡剂_蓝星_海明斯德谦_广百进口消泡剂 | 证券新闻,热播美式保罗1984第二部_腾讯1080p-仁爱影院 | 金属雕花板_厂家直销_价格低-山东慧诚建筑材料有限公司 | 骨密度仪-骨密度测定仪-超声骨密度仪-骨龄测定仪-天津开发区圣鸿医疗器械有限公司 | 膏方加工_丸剂贴牌_膏滋代加工_湖北康瑞生物科技有限公司 | 新密高铝耐火砖,轻质保温砖价格,浇注料厂家直销-郑州荣盛窑炉耐火材料有限公司 | 电渗析,废酸回收,双极膜-山东天维膜技术有限公司 | 水冷散热器_水冷电子散热器_大功率散热器_水冷板散热器厂家-河源市恒光辉散热器有限公司 | 橡胶粉碎机_橡胶磨粉机_轮胎粉碎机_轮胎磨粉机-河南鼎聚重工机械制造有限公司 | 杭州火蝠电商_京东代运营_拼多多全托管代运营【天猫代运营】 | 东莞动力锂电池保护板_BMS智能软件保护板_锂电池主动均衡保护板-东莞市倡芯电子科技有限公司 | 生物颗粒燃烧机-生物质燃烧机-热风炉-生物颗粒蒸汽发生器-丽水市久凯能源设备有限公司 | 滚筒烘干机_转筒烘干机_滚筒干燥机_转筒干燥机_回转烘干机_回转干燥机-设备生产厂家 | 婚博会2024时间表_婚博会门票领取_婚博会地址-婚博会官网 | 全自动包装机_灌装机生产厂家-迈驰包装设备有限公司 | 精密钢管,冷拔精密无缝钢管,精密钢管厂,精密钢管制造厂家,精密钢管生产厂家,山东精密钢管厂家 | 新型锤式破碎机_新型圆锥式_新型颚式破碎机_反击式打沙机_锤式制砂机_青州建源机械 | 诚暄电子公司首页-线路板打样,pcb线路板打样加工制作厂家 | 衢州装饰公司|装潢公司|办公楼装修|排屋装修|别墅装修-衢州佳盛装饰 | 上海道勤塑化有限公司| 江苏齐宝进出口贸易有限公司| 暴风影音 | 宝元数控系统|对刀仪厂家|东莞机器人控制系统|东莞安川伺服-【鑫天驰智能科技】 | 电磁辐射仪-电磁辐射检测仪-pm2.5检测仪-多功能射线检测仪-上海何亦仪器仪表有限公司 | 写方案网_方案策划方案模板下载| 定量包装机,颗粒定量包装机,粉剂定量包装机,背封颗粒包装机,定量灌装机-上海铸衡电子科技有限公司 | 大米加工设备|大米加工机械|碾米成套设备|大米加工成套设备-河南成立粮油机械有限公司 |