我不知道这段代码是怎么回事。我从不同角度研究了可能导致此问题的原因,而一切都没有了。
因此,问题是在经过一定数量的字符后,我的代码试图在字符串contcat期间自行执行字符串以使其双重转换。我一直在寻找没有转换为字符串的输入,检查是否缺少“或+”操作数,甚至尝试过移动代码的各个部分,以查看是否是引起问题的特定页面控件值。
什么都没用,无论我在串联中输入什么字段,它都会尝试将字符串转换为大约16至20个字符后的双精度字符。
这是引起问题的连接器
thCValLst = "AhcccsGroup = " + If(ThCredAhcsGrpCBox.Checked, "1", "0") + ", NPI = '" + ThCredNPITBox.Text + "', AhcccsActive = " + If(ThCredAhcsActCBox.Checked, "1", "0") + "', DriversLicense = '"
thCValLst += ThCredDrvLicTBox.Text + "', EINNumber = '" + ThCredEINTBox.Text + "', Credentials = '" + ThCredCredTBox.Text + "', Contracted = '" + ThCredConTBox.Text + "', Notes = '" + ThCredNotesTBox.Text + "', CPRExpDate = '"
thCValLst += CType(ThCredCPREDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', LCRExpDate = '" + CType(ThCredLCREDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', FingerPrintTakenDate = '"
thCValLst += CType(ThCredFPTDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', FingerPrintExpDate = '" + CType(ThCredFPEDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', LicenseNumber = '" + ThCredLicNumTBox.Text
thCValLst += "', LicenseExpDate = '" + CType(ThCredLEDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', InsuranceExpDate = '" + CType(ThCredIEDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', Article9ExpDate = '"
thCValLst += CType(ThCredA9DDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "', MalpracticeDate = " + If(ThCredMPDDTP.SelectedDate Is Nothing, "NULL", "'" + CType(ThCredMPDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "'")
thCValLst += ", PreSuppExpiration = " + If(ThCredPSEDDTP.SelectedDate Is Nothing, "NULL", "'" + CType(ThCredPSEDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd") + "'") + ", TermDate = '" + CType(ThCredTDDTP.SelectedDate, DateTime).ToString("yyyy-MM-dd")
thCValLst += "', BillingAuthSheet = " + If(ThCredABSCBox.Checked, "1", "0") + ", SignedContract = " + If(ThCredSCCBox.Checked, "1", "0") + ", PayrollInfo = " + If(ThCredPRICBox.Checked, "1", "0") + ", W9 = " + If(ThCredW9CBox.Checked, "1", "0")
thCValLst += ", Resume = " + If(ThCredResCBox.Checked, "1", "0") + ", Referenece = " + If(ThCredRefCBox.Checked, "1", "0") + ", Orientation = " + If(ThCredOrtCBox.Checked, "1", "0") + ", InsCode1 = '" + ThCredInsCd1TBox.Text + "', InsCode2 = '"
thCValLst += ThCredInsCd2TBox.Text + "', Facility = '" + ThCredFacTBox.Text = "', ModifiedOn = GetDate(), ModifiedBy = '" + curUsr.GetUsrName() + "'"
在上面的代码中,执行将到达NPI值的第八个字符,然后再引发两次转换错误,我将在下面全部添加该错误。
thCValLst定义为:Dim thCValLst As String =“”,直到我的代码中的这一点才使用。我在代码上方还有其他这样的concat,它们很好。我觉得我错过了一些东西,但我不知道该怎么办。一切看起来都应该正确。
未捕获的Sys.WebForms.PageRequestManagerServerErrorException:Sys.WebForms.PageRequestManagerServerErrorException:从字符串“ AhcccsGroup = 1,NPI ='12345678”到类型'Double'的转换无效。 在Function.Error.create(https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:6:2736) 在Sys.WebForms.PageRequestManager._createPageRequestManagerServerError(https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:15:11490) 在Sys.WebForms.PageRequestManager._parseDelta(https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:15:29608) 在Sys.WebForms.PageRequestManager._onFormSubmitCompleted(https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:15:25637) 在阵列。 (https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:6:307) 在https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:6:51370 在Sys.Net.WebRequest.completed(https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:6:89728处) 在XMLHttpRequest._onReadyStateChange(https://clinic.h2tportal.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_MainContent_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9c7ac0d-8fa4-44a7-8b1a-8b20d0589515%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a48e0f2bb-99f7-43cd-9b8e-5b9bce752872%3a16e4e7cd%3af7645509%3a22a6274a%3a24ee1bba%3ae330518b%3a2003d0b8%3ac128760b%3a88144a7a%3a1e771326%3ac8618e41%3a1a73651d%3a16d8629e%3aed16cbdc%3a962f9868%3a73973f5b%3a578015a3%3af46195d3%3a58366029%3aaa288e2d%3a258f1c72%3ae4f8f289%3a333f8d94%3a4cd1fec6%3a77613e24%3af0c58c30%3a9b7cc2d2%3a69667591%3aec7335e%3ad944e0f6%3ac442ac3f%3a8d1fecce%3a6b6b9ee5%3a595e7652%3a92fe8ea0%3afa31b949%3a4877f69a%3a874f8ea2%3a19620875%3a490a9d4e%3a7c926187%3a8674cba1%3a2e42e72a%3aef347303%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a82923ac3%3a6d43f6d9%3ac172ae1e%3a9cdfc6e7:6:84327)
答案 0 :(得分:0)
老实说,我惊讶您的代码甚至可以编译,因为每行末尾没有String连接符号。
要考虑的一点是,虽然在Visual Basic中使用type a b = ...?
运算符来连接字符串是有效的,但最好使用+
运算符。这样可以避免String串联与用于加法的数学运算符之间的任何歧义。
还要考虑的另一件事是,根据所使用的Visual Studio版本,您应该考虑使用String插值或String.Format来格式化String。
字符串插值 在Visual Basic 14中引入了它,您可以对字符串进行插值。以下代码中的两行返回相同的String(假定变量名称):
&
在这种情况下,变量1,变量2和变量3表示的值将包含在字符串中,但是请注意,读取字符串文字要容易得多。更重要的是,Visual Studio IDE对插值变量的着色方式不同。
String.Format 是String插值的先驱。以下代码中的两行与上述操作相同:
Dim foo As String = $"{variable1}: {variable2} - {variable3}"
Dim bar As String = variable1 & ": " & variable2 & " - " & variable2
我建议您使用概述的两种方法之一,看看是否有帮助。
P.S。 -我注意到您正在进行一些类型转换,例如Dim foo As String = String.Format("{0}: {1} - {2}", variable1, variable2, variable3)
Dim bar As String = variable1 & ": " & variable2 & " - " & variable2
。确实没有任何理由,因为您是将其从Date转换为Date再转换为String。如果要将DateTime变量转换为String,请调用ToString方法,同时可以选择传递所需的格式:CType(ThCredFPTDDTP.SelectedDate, DateTime)
该建议无效,因为这些控件是自定义的第三方控件
P.S.S。 -在我们交谈之后,确定您从中继承代码的人正在尝试通过传递查询字符串中的值(即使用无参数查询)来构建SQL查询字符串。我建议您转换代码以利用参数来获得明显的SQL好处,同时也可以提高可读性。