我在Windows窗体中获得了以下代码,但是我收到了错误
重载解析失败,因为没有可访问的'ExecuteNonQuery'接受此数量的参数
我四处搜寻,我看到的一切似乎与参数的数量有关。我正在提供代码所期望的数字(43),有人能指出我正确的方向吗?
Public Class wfRecDB
Dim cn As New SqlConnection("Data Source=.;Initial Catalog=RecDb;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Private Sub wfRecDB_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
cmd.Connection = cn
End Sub
Private Sub btnCon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCon.Click
If cbEnv.Text <> "" Then
cn.Open()
cmd.CommandText = "insert into recdb.recs.recdbextract (Environment,Unreconciled,Reconciled,Account,AcctRel,AccInc,AcctPro,Address,AssClass,BankAcc,BrkRel,CBNwork,CCTE,CIB,ClCont,ClCparty,ClFatca,ClFatcaDet,ExtRef,FamGp,FundLd,GenVar,IsaDec,LocStr,MPLocPat,MPOutPat,MPPatDet,MPPatHead,MPProdPat,NomAcc,NomAccLink,OutAssCl,OutMktCam,SippAcc,SippBCE,SippBenReq,SippLta,SippPaye,SippPenInc,SippRegPay,UnitPrice,UserGroups,UserPerms) values ('" & cbEnv.Text & "','" & rbUnreconciled.Text & "','" & rbReconciled.Text & "','" & cbAccount.Text & "', '" & cbAccountRelationship.Text & " ','" & cbAccountIncomeDistributionChoice.Text & "','" & cbAccountProfile.Text & "','" & cbAddress.Text & "','" & cbAssetClassification.Text & "','" & cbBankAccount.Text & "','" & cbBrokerRelationship.Text & "','" & cbClientBroker.Text & "','" & cbClientCorp.Text & "','" & cbClientInd.Text & "','" & cbClientContext.Text & "','" & cbClientCparty.Text & "','" & cbClientFATCA.Text & "','" & cbClientFATCADetails.Text & "','" & cbExtRefPlfmOne.Text & "','" & cbFamilyGroups.Text & "','" & cbFundLoader.Text & "','" & cbGenericVariables.Text & "','" & cbIsadec.Text & "','" & cbLocationStructure.Text & "','" & cbtbMPLocation.Text & "','" & cbMPOut.Text & "','" & cbPatDet.Text & "','" & cbPatHead.Text & "','" & cbProd.Text & "','" & cbNomAcc.Text & "','" & cbNomAccLink.Text & "','" & cbAssetClassification.Text & "','" & cbOutCam.Text & "','" & cbSIPPAcc.Text & "','" & cbSIPPBCE.Text & "','" & cbSIPPBen.Text & "','" & cbSIPPLTA.Text & "','" & cbSIPPPAYE.Text & "','" & cbSIPPPen.Text & "','" & cbSIPPReg.Text & "','" & cbUnitPrice.Text & "','" & cbUserGroups.Text & "','" & cbUserPerm.Text & "')"
cmd.ExecuteNonQuery("")
cn.Close()
cbEnv.Text = ""
rbUnreconciled.Text = ""
rbReconciled.Text = ""
End If
End Sub
答案 0 :(得分:3)
错误非常明显 - ExecuteNonQuery()
没有过载需要一个字符串参数,因为您在这里提供:
cmd.ExecuteNonQuery("")
ExecuteNonQuery()
期望无参数 - 所以只需将该行代码更改为
cmd.ExecuteNonQuery()
你应该没事。