简体   繁体   English

无法从Visual Basic更新CSV文件上的数据

[英]Unable to update the data on CSV file from Visual Basic

I have some data in CSV format which needs to be updated from Visual Basic code. 我有一些CSV格式的数据,需要从Visual Basic代码中进行更新。

While updating the record, I am getting the error 更新记录时,出现错误

[Microsoft][ODBC Text Driver] Updating data in a linked table is not supported by this ISAM. [Microsoft] [ODBC文本驱动程序]此ISAM不支持更新链接表中的数据。

I have created a DSN named as "dsncsv". 我创建了一个名为“ dsncsv”的DSN。

Here is my code: 这是我的代码:

Dim ExcelCon As New ADODB.Connection
Dim ExcelRs As New ADODB.Recordset

ExcelCon.ConnectionString = "dsncsv"
ExcelCon.Open

Dim SqlCmd As New ADODB.Command
SqlCmd.ActiveConnection = ExcelCon

SqlCmd.CommandText = "update test1.csv set Accoun='" & NM & "'"
SqlCmd.Execute

How can I resolve this? 我该如何解决?

Not quite an answer, but what you are trying to do should be possible. 不是一个完全的答案,但是您尝试做的事情应该是可能的。 Can you show the source of the DSN you are using, or make it part of the code directly, rather than referencing "dsncsv". 您可以显示正在使用的DSN的源代码,还是直接使其成为代码的一部分,而不是引用“ dsncsv”? DSNs are a very irritating thing sometimes. DSN有时是非常令人讨厌的事情。

You might try switching to FileHelpers instead of going through ado for this. 您可以尝试切换到FileHelpers而不是为此忙碌 That library works quite well for this kind of work. 该库对于这种工作非常有效。

From the site: 从站点:

You can strong type your flat file (fixed or delimited) simply describing a class that maps to each record and later read/write your file as an strong typed .NET array 您可以简单地描述一个映射到每个记录的类,然后对一个平面文件进行强类型(固定或定界),然后再以强类型.NET数组读取/写入文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM