Foxtable(狐表)用户栏目专家坐堂 → [求助]Exporter导出数据到mdb文件怎么[_Identify]列丢失了


  共有2729人关注过本帖树形打印复制链接

主题:[求助]Exporter导出数据到mdb文件怎么[_Identify]列丢失了

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/20 21:20:00 [显示全部帖子]

参考代码

 

Dim t As Table = CurrentTable
Dim str_oleConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\test.mdb;Persist Security Info=False"
Dim ole_conn As New System.Data.OleDb.OleDbConnection(str_oleConn)
Try
    ole_conn.Open()
    Dim str As String = "_Identify AUTOINCREMENT PRIMARY KEY,"
    For Each c As Col In CurrentTable.cols
        str &= c.name & " char(16),"
    Next
    output.show(str)
    Dim cmd1 As New System.Data.OleDb.OleDbCommand("Create Table " &  t.name & " (" & str.Trim(",") & ")", ole_conn)
    cmd1.ExecuteNonQuery()
   
    For Each r As Row In t.rows
        str = "'" & r("_Identify") & "',"
        For Each c As Col In t.cols
            str &= "'" & r(c.name) & "',"
        Next
        Dim cmd2 As New System.Data.OleDb.OleDbCommand("Insert Into " & t.name & " values (" & str.Trim(",")  & ")", ole_conn)
        output.show(str)
        cmd2.ExecuteNonQuery()
    Next
    msgbox("保存成功")
Catch ex As Exception
    MessageBox.Show(ex.Message)
Finally
    ole_conn.Close()
End Try

 


 回到顶部