Dim sConnection As String = "Data Source = svr1066; Initial Catalog =
PFSEditTest; Integrated Security = SSPI;"
myCommand.CommandText = "INSERT INTO
PFSEditTestTable(DateFiled, PersonReporting,
PhoneNumber, PriorityLevel, EffectiveDate, EditType, EditFileName,
BillingEntity,QueueAssignment, System, SystemNote, FormTypes, BillTypes,
PayersNote, Payers, Examples, DescriptionOfEdit, CompletedPieReceived,
WFIDate, WFIPerson, DueDate, CompletedDate, Method, AssignedTo, Status,
EditNames, TestExamples, TestCriteria)Values (@DateFiled,
@PersonReporting, @PhoneNumber, @PriorityLevel, @EffectiveDate, @EditType,
@EditFileName, @BillingEntity, @QueueAssignment, @System, @SystemNote,
@FormTypes, @BillTypes, @PayersNote, @Payers,
@Examples, @DescriptionOfEdit, @CompletedPieReceived, @WFIDate, @WFIPerson,
@DueDate, @CompletedDate, @Method, @AssignedTo, @Status, @EditNames,
@TestExamples, @TestCriteria)
myCommand.ExecuteNonQuery()
我试图将值插入服务器上的测试数据库中。我查看了其他帖子,我不知道SSMS中的哪个位置有Edit下的Intellisense选项。我可能遗漏了一些东西。我已使用SQL Server对象资源管理器测试了查询,并使用此查询正确执行:SELECT * FROM PFSEditTestTable在此数据库上运行:PFSEditTest。
答案 0 :(得分:0)
我怀疑VB会编译缺少的引用,但这是我所看到的所有内容而没有更多信息。
Dim sConnection As String = "Data Source = svr1066; Initial Catalog =
PFSEditTest; Integrated Security = SSPI;"
myCommand.CommandText = "INSERT INTO
PFSEditTestTable (DateFiled, PersonReporting,
PhoneNumber, PriorityLevel, EffectiveDate, EditType, EditFileName,
BillingEntity,QueueAssignment, System, SystemNote, FormTypes, BillTypes,
PayersNote, Payers, Examples, DescriptionOfEdit, CompletedPieReceived,
WFIDate, WFIPerson, DueDate, CompletedDate, Method, AssignedTo, Status,
EditNames, TestExamples, TestCriteria)
Values (@DateFiled, --<-- Values was flush with )
@PersonReporting, @PhoneNumber, @PriorityLevel, @EffectiveDate, @EditType,
@EditFileName, @BillingEntity, @QueueAssignment, @System, @SystemNote,
@FormTypes, @BillTypes, @PayersNote, @Payers,
@Examples, @DescriptionOfEdit, @CompletedPieReceived, @WFIDate, @WFIPerson,
@DueDate, @CompletedDate, @Method, @AssignedTo, @Status, @EditNames,
@TestExamples, @TestCriteria)" --<-- missing quotation mark
myCommand.ExecuteNonQuery()
答案 1 :(得分:-1)
默认情况下,分配给SQL命令的字符串是将要执行的存储过程的名称。在这种情况下,您没有使用任何存储过程,因此您需要定义命令的类型。 在调用ExecuteNonQuery语句之前添加此语句以解决错误:
myCommand.CommandType = CommandType.Text;