vb 如何把txt文件导入ACCESS数据库?

casper_moonzhang 2006-10-31 03:31:52
如何把txt文件导入ACCESS数据库?
如何把ACCESS数据库内容导出到txt文件?
最好能给个小例子!
...全文
195 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
copico 2006-10-31
  • 打赏
  • 举报
回复 1
[Visual Basic]
Imports System
Imports System.IO
Imports System.Text

Public Class Test

Public Shared Sub Main()
Dim path As String = "c:\temp\MyTest.txt"

' Delete the file if it exists.
If File.Exists(path) Then
File.Delete(path)
End If

'Create the file.
Dim fs As FileStream = File.Create(path)

AddText(fs, "This is some text")
AddText(fs, "This is some more text,")
AddText(fs, Environment.NewLine & "and this is on a new line")
AddText(fs, Environment.NewLine & Environment.NewLine)
AddText(fs, "The following is a subset of characters:" & Environment.NewLine)

Dim i As Integer

For i = 1 To 120
AddText(fs, Convert.ToChar(i).ToString())

'Split the output at every 10th character.
If Math.IEEERemainder(Convert.ToDouble(i), 10) = 0 Then
AddText(fs, Environment.NewLine)
End If
Next

fs.Close()

'Open the stream and read it back.
fs = File.OpenRead(path)
Dim b(1024) As Byte
Dim temp As UTF8Encoding = New UTF8Encoding(True)

Do While fs.Read(b, 0, b.Length) > 0
Console.WriteLine(temp.GetString(b))
Loop

fs.Close()
End Sub

Private Shared Sub AddText(ByVal fs As FileStream, ByVal value As String)
Dim info As Byte() = New UTF8Encoding(True).GetBytes(value)
fs.Write(info, 0, info.Length)
End Sub
End Class

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧