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>
                            主站蜘蛛池模板: 无硅导热垫片-碳纤维导热垫片-导热相变材料厂家-东莞市盛元新材料科技有限公司 | 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 谷梁科技| 不锈钢水管-不锈钢燃气管-卫生级不锈钢管件-不锈钢食品级水管-广东双兴新材料集团有限公司 | 德国进口电锅炉_商用电热水器_壁挂炉_电采暖器_电热锅炉[德国宝] | 酒糟烘干机-豆渣烘干机-薯渣烘干机-糟渣烘干设备厂家-焦作市真节能环保设备科技有限公司 | DWS物流设备_扫码称重量方一体机_快递包裹分拣机_广东高臻智能装备有限公司 | 酒吧霸屏软件_酒吧霸屏系统,酒吧微上墙,夜场霸屏软件,酒吧点歌软件,酒吧互动游戏,酒吧大屏幕软件系统下载 | 卫生纸复卷机|抽纸机|卫生纸加工设备|做卫生纸机器|小型卫生纸加工需要什么设备|卫生纸机器设备多少钱一台|许昌恒源纸品机械有限公司 | 上海冠顶工业设备有限公司-隧道炉,烘箱,UV固化机,涂装设备,高温炉,工业机器人生产厂家 | 合肥汽车充电桩_安徽充电桩_电动交流充电桩厂家_安徽科帝新能源科技有限公司 | 冷却塔降噪隔音_冷却塔噪声治理_冷却塔噪音处理厂家-广东康明冷却塔降噪厂家 | 基本型顶空进样器-全自动热脱附解吸仪价格-AutoHS全模式-成都科林分析技术有限公司 | 四川职高信息网-初高中、大专、职业技术学校招生信息网 | 周口风机|周风风机|河南省周口通用风机厂 | 定制液氮罐_小型气相液氮罐_自增压液氮罐_班德液氮罐厂家 | 胜为光纤光缆_光纤跳线_单模尾纤_光纤收发器_ODF光纤配线架厂家直销_北京睿创胜为科技有限公司 - 北京睿创胜为科技有限公司 | 清管器,管道清管器,聚氨酯发泡球,清管球 - 承德嘉拓设备 | 机器视觉检测系统-视觉检测系统-机器视觉系统-ccd检测系统-视觉控制器-视控一体机 -海克易邦 | 油漆辅料厂家_阴阳脚线_艺术漆厂家_内外墙涂料施工_乳胶漆专用防霉腻子粉_轻质粉刷石膏-魔法涂涂 | 高低温老化试验机-步入式/低温恒温恒湿试验机-百科 | 电镀标牌_电铸标牌_金属标贴_不锈钢标牌厂家_深圳市宝利丰精密科技有限公司 | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 志高装潢官网-苏州老房旧房装修改造-二手房装修翻新 | 湖南成人高考报名-湖南成考网 | 智能门锁电机_智能门锁离合器_智能门锁电机厂家-温州劲力智能科技有限公司 | 济南网站策划设计_自适应网站制作_H5企业网站搭建_济南外贸网站制作公司_锐尚 | 污水处理设备维修_污水处理工程改造_机械格栅_过滤设备_气浮设备_刮吸泥机_污泥浓缩罐_污水处理设备_污水处理工程-北京龙泉新禹科技有限公司 | 工控机,嵌入式主板,工业主板,arm主板,图像采集卡,poe网卡,朗锐智科 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 金属切削液-脱水防锈油-电火花机油-抗磨液压油-深圳市雨辰宏业科技发展有限公司 | 临沂招聘网_人才市场_招聘信息_求职招聘找工作请认准【马头商标】 | 细沙回收机-尾矿干排脱水筛设备-泥石分离机-建筑垃圾分拣机厂家-青州冠诚重工机械有限公司 | 硬度计_影像测量仪_维氏硬度计_佛山市精测计量仪器设备有限公司厂家 | 鲁尔圆锥接头多功能测试仪-留置针测试仪-上海威夏环保科技有限公司 | 校园文化空间设计-数字化|中医文化空间设计-党建|法治廉政主题文化空间施工-山东锐尚文化传播公司 | 钢托盘,铁托盘,钢制托盘,镀锌托盘,饲料托盘,钢托盘制造商-南京飞天金属13260753852 | 英国公司注册-新加坡公司注册-香港公司开户-离岸公司账户-杭州商标注册-杭州优创企业 | 中高频感应加热设备|高频淬火设备|超音频感应加热电源|不锈钢管光亮退火机|真空管烤消设备 - 郑州蓝硕工业炉设备有限公司 | 专业生产动态配料系统_饲料配料系统_化肥配料系统等配料系统-郑州鑫晟重工机械有限公司 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 |