We are having a problem related to paste clipboard. We are extracting block attribute to MS access file using VB.net.
While extracting block data, all block object in paste clipboard is also exported to MS access file. Kindly guide to clear paste clip board using VB.net before exporting block attribute data. We want to extract block object existing in drawing only. Thanks in advance.
Could you explain in detail how the block data is extracted and showing the code of doing it? Saving data into a database, be it is MS Access, or other types of database, is a fairly common task doing by code. I cannot see why clip board is involved, or needed.
Hi,
Clipboard is a class of System.Windows... so yo can call ClipBoard.Clear or any other method: ClipBoard Class
Gaston Nunez
Here is working code from one of winform application
The last part of code is borrowed from MSDN article,
change full path of ms access file and table name:
Public Shared Sub TestMSAcessToClipboard() Dim conn As New System.Data.OleDb.OleDbConnection() conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "C:\Test\MyBlocks.accdb" + ";Jet OLEDB:Database Password=;" conn.Open() Dim dt As New System.Data.DataTable() Dim oleCmd As New System.Data.OleDb.OleDbCommand("SELECT * From [" + "MyBlocks" + "]", conn) Using oleRead As System.Data.OleDb.OleDbDataReader = oleCmd.ExecuteReader() dt.Load(oleRead) oleRead.Close() End Using Dim rows As System.Data.DataRow() = dt.Select() conn.Close() Dim sb As New StringBuilder() For Each row As System.Data.DataRow In rows Dim str As String = String.Empty For col As Integer = 0 To row.ItemArray.Length - 1 str = str & row(col).ToString() & vbTab Next sb.AppendLine(str) Next Dim stack As Boolean = True Dim data As New DataObject(DirectCast(sb.ToString(), Object)) If stack Then ' Place the persisted data on the clipboard. Clipboard.SetDataObject(data, True) Else ' Place the non-persisted data on the clipboard. Clipboard.SetDataObject(data, False) End If MessageBox.Show("Paste this data to text or csv file") End Sub