请帮助我看一下这处程序:如何将Access(*.mdb)文件转换为其它的文件格式?

jzp12 2007-06-04 10:04:40
我想实现将其转换为如格式的文件.
*.DBF
*.MDB
*.XLS
*.DB
现在已经现实转换为*.XLS格式的文件,
但是其它的都不能,实现程序代码如下:帮我看看到底那里错了?

Public Class Form1
Inherits System.Windows.Forms.Form
Dim conn As New ADODB.Connection
Dim rsExport As New ADODB.Recordset

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Dialog1 As System.Windows.Forms.SaveFileDialog
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Protected Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.RadioButton4 = New System.Windows.Forms.RadioButton
Me.Button1 = New System.Windows.Forms.Button
Me.Dialog1 = New System.Windows.Forms.SaveFileDialog
Me.DataGrid1 = New System.Windows.Forms.DataGrid
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'RadioButton1
'
Me.RadioButton1.Location = New System.Drawing.Point(24, 32)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(120, 24)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "Foxpro格式"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(24, 96)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "Access格式"
'
'RadioButton3
'
Me.RadioButton3.Location = New System.Drawing.Point(216, 32)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(128, 24)
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "Excel格式"
'
'RadioButton4
'
Me.RadioButton4.Location = New System.Drawing.Point(216, 96)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.Size = New System.Drawing.Size(120, 24)
Me.RadioButton4.TabIndex = 3
Me.RadioButton4.Text = "Paradox4.x格式"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(104, 160)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(136, 40)
Me.Button1.TabIndex = 4
Me.Button1.Text = "转换"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(256, 128)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.TabIndex = 5
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(432, 270)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.RadioButton4)
Me.Controls.Add(Me.RadioButton3)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'连接数据可并打开记录集
conn.CursorLocation = ADODB.CursorLocationEnum.adUseServer
conn.Open("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\jzp.mdb;")
rsExport.Open("Select * from Customers", conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) '初始化对话框

With Dialog1
.Filter = "FoxBase/FoxPro(*.DBF)|*.DBF|Access8.0(*.MDB)|*.MDB|Excel8.0(*.XLS)|*.XLS|Paradox4.x(*.DB)|*.DB"
.Title = "导出文件为"
End With
End Sub
...全文
241 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jzp12 2007-06-04
  • 打赏
  • 举报
回复
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myPath As Object
Dim myStr As String
Dim myPos As Short
Dim mdbTable As String
Dim Export_Str As Object
Try
'**************处理选择的各种表的导出
With Dialog1
If RadioButton1.Checked Then
.FilterIndex = 1
.ShowDialog()
myStr = StrReverse(.FileName) '串取反
myPos = InStr(myStr, "\") '在反字符串中,找从左开始第一个位置
myPath = StrReverse(Mid(myStr, myPos)) '取目录部分,并还原。
myStr = StrReverse(Strings.Left(myStr, myPos - 1)) '取文件名
Export_Str = "select * into [dBaseⅢ;database= " & myPath & "]." & myStr & "from Customers"
.DefaultExt = "*.DBF"
ElseIf RadioButton2.Checked Then
mdbTable = InputBox("请给导出到MDB文件的表确定表名")
.FilterIndex = 2
.ShowDialog()
Export_Str = "select * into [;database= " & .FileName & "]." & mdbTable & "from Customers"
.DefaultExt = "*.MDB"
ElseIf RadioButton3.Checked Then
.FilterIndex = 3
.ShowDialog()
Export_Str = "select * into [Excel 8.0;database=" & .FileName & "].Customers from Customers"
.DefaultExt = "*.XLS"
ElseIf RadioButton4.Checked Then
.FilterIndex = 4
.ShowDialog()
myStr = StrReverse(.FileName) '串取反
myPos = InStr(myStr, "\") '在反字符串中,找从左开始第一个\的位置
myPath = StrReverse(Strings.Left(myStr, myPos - 1)) '取文件名
Export_Str = "select * into [Paradox4.X;database=" & myPath & "]." & myStr & " from Customers"
.DefaultExt = "*.DB"
End If
End With

'************生成文件
System.Diagnostics.Debug.WriteLine(Export_Str)
If rsExport.State = 1 Then
rsExport.Close()
End If
If Dir(Dialog1.FileName) <> "" Then
'防用户没选文件
If Dialog1.FilterIndex <> 2 Then
Kill((Dialog1.FileName))
End If
rsExport.Open(Export_Str, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
Else
rsExport.Open(Export_Str, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

End If
Catch
Exit Sub
End Try
End Sub

Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate

End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

End Sub

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged

End Sub
End Class
2024 年 Uber 乘车分析数据集 这个综合数据集包含 2024 年 Uber 运营的详细拼车数据,提供了有关预订模式、车辆性能、收入流、取消行为和客户满意度指标的丰富见解。 数据集概述 该数据集捕获了多种车辆类型的 148,770 个总预订,并提供了拼车作的完整视图,包括成功乘车、取消、客户行为和财务指标。 主要统计数据: 总预订量:148.77K 次乘车 成功率:65.96%(93K 完成骑行) 取消率:25%(37.43K 取消预订) 客户取消:19.15%(27K 乘车) 司机取消: 7.45% (10.5K 乘车) 数据模式 数据集包含以下列: 列名称 描述 Date 预订日期 Time 预订时间 Booking ID 每次行程预订的唯一标识符 Booking Status 预订状态(已完成、客户取消、司机取消等) Customer ID 客户的唯一标识符 Vehicle Type 车辆类型(Go Mini、Go Sedan、Auto、eBike/Bike、UberXL、Premier Sedan) Pickup Location 游乐设施的起点 Drop Location 乘车目的地 Avg VTAT 司机到达上车地点的平均时间(以分钟为单位) Avg CTAT 从取件到目的地的平均行程时间(以分钟为单位) Cancelled Rides by Customer 客户发起的取消标志 Reason for cancelling by Customer 客户取消原因 Cancelled Rides by Driver 驱动程序启动的取消标志 Driver Cancellation Reason 司机取消原因 Incomplete Rides 未完成骑行标志 Incomplete Rides Reason 不完整骑行的原因

16,722

社区成员

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

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