本文介绍了将表从msaccess导出到桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i希望在点击按钮时使用插入openrowset将我的msaccess表导出到桌面

im在INSERT INTO语句中获取错误



请有人帮帮我。

这是我的代码:





 公共  XtraForm3 

私有 Sub SimpleButton1_Click(发件人 As System。 Object ,e As System.EventArgs)句柄 SimpleButton1.Click
Dim folderbrowserdialog1 As FolderBrowserDialog
' folderbrowserdialog1.ShowD ialog()
' 如果folderbrowserdialog1.ShowDialog()= DialogResult.OK那么
' MessageBox.Show(folderbrowserdialog1.SelectedPath)
End If
If (folderbrowserdialog1.ShowDialog ()= DialogResult.OK)然后
TextEdit1.Text = folderbrowserdialog1.SelectedPath
结束 如果

InsertData()
结束 Sub

私有 Sub InsertData()
Dim queryString As 字符串 = INSERT INTO OPENROWSET('Provider = Microsoft.Jet.OLEDB.4.0;数据源= C:\ DMT.net \mdb \ Edata2.mdb;','SELECT * FROM ArtBez')

Dim conn 作为 System.Data。 OleDb.OleDbConnection( Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\ DMT.net \\ \\ mdb\Edata2.mdb

Dim cmd As System.Data.OleDb.OleDbCommand(queryString,conn)
conn.Open()
cmd.CommandType = CommandType.Text
Dim adapter As 系统.Data.OleDb.OleDbDa taAdapter(cmd)
cmd.ExecuteNonQuery()
conn.Close()

结束 Sub
结束 Class
解决方案

Hi all,
i want to export my msaccess tables to desktop on click of the button using "insert into openrowset"
i m getting error in "INSERT INTO" statement

please someone help me with this.
Here is my code:


Public Class XtraForm3

    Private Sub SimpleButton1_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
        Dim folderbrowserdialog1 As New FolderBrowserDialog
        'folderbrowserdialog1.ShowDialog()
        'If folderbrowserdialog1.ShowDialog() = DialogResult.OK Then
        '    MessageBox.Show(folderbrowserdialog1.SelectedPath)
        'End If
        If (folderbrowserdialog1.ShowDialog() = DialogResult.OK) Then
            TextEdit1.Text = folderbrowserdialog1.SelectedPath
        End If

        InsertData()
    End Sub

    Private Sub InsertData()
        Dim queryString As String = "INSERT INTO OPENROWSET ('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DMT.net\mdb\Edata2.mdb;', 'SELECT * FROM ArtBez')"

        Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DMT.net\mdb\Edata2.mdb")

        Dim cmd As New System.Data.OleDb.OleDbCommand(queryString, conn)
        conn.Open()
        cmd.CommandType = CommandType.Text
        Dim adapter As New System.Data.OleDb.OleDbDataAdapter(cmd)
        cmd.ExecuteNonQuery()
        conn.Close()

    End Sub
End Class
解决方案


这篇关于将表从msaccess导出到桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 00:34