Storing Block attribute information

Storing Block attribute information

Anonymous
Not applicable
475 Views
3 Replies
Message 1 of 4

Storing Block attribute information

Anonymous
Not applicable
I am trying to figure out how to develop either an MS Access or SQL database that will store block attributes (make, model, price, electrical/plumbing utilities). Which I could then export to Excel to develop budget and bill of material lists/utility schedules.

I'd like to be able to insert a block into a drawing and have the Excel spreadsheet update with the respective attribute information.

I'm new to customization/programming and feel like I'm biting off more than I can chew right at the moment.
0 Likes
476 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor
You might want to look at DbConnect in Autocad. It doesn't require programming.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable
If you need to read data contents easier yet
to use OleDB methods
Attached is edited version I've found on this forum
See how it will works for you
For the testing create the form with DataGridView and add
one Button
Change database path and table name and fields in
connection string
Hth

~'J'~

Imports System.Data
Imports System.Data.OleDb
Imports ADODB
'// Note :
'// Add reference to Microsoft ActiveX Data Objects 2.X Library
'//
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create a connection string
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\MyData\MyBlocks.mdb"
' Select fields from table Blocks
Dim sql As String = "SELECT BlockName, TAG1, TAG2, TAG3, TAG4 From Blocks"
' Create a Connection object and open it
Dim conn As Connection = New Connection
Dim connMode As Integer = ConnectModeEnum.adModeUnknown
conn.CursorLocation = CursorLocationEnum.adUseServer
conn.Open(ConnectionString, "", "", connMode)
Dim recAffected As Object = Nothing
Dim cmdType As Integer = CommandTypeEnum.adCmdText
Dim rs As _Recordset = conn.Execute(sql)
' Create dataset and data adpater objects
Dim ds As DataSet = New DataSet("$Recordset$")
Dim da As OleDbDataAdapter = New OleDbDataAdapter
' Call data adapter's Fill method to fill data from ADO
' Recordset to the dataset
da.Fill(ds, rs, "Blocks")
' Now use dataset
DataGridView1.DataSource = ds.Tables(0)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Get data from selected row(s)
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows.Item(i).Selected Then
For j As Integer = 0 To DataGridView1.Columns.Count - 1
MsgBox("Row " & i + 1 & ", Column " & j + 1 & " value: " & DataGridView1.Item(j, i).Value.ToString)
Next
End If
Next
Me.Close()
Me.Dispose()
End Sub

End Class
0 Likes
Message 4 of 4

Anonymous
Not applicable
Since you say you are new to programming I would recommend using VBA.
It is much much easier to learn and understand than any of the .NET languages. Plus you will find that there is a lot more samples and examples of code for what you want to do.
0 Likes