Anybody tried pulling custom properties from ODBS or SQL Server using SW macro
I think this is little bit over my head, but I'm willing to learn
Looking for some tutorials, code examples or anything to get me started
Anybody tried pulling custom properties from ODBS or SQL Server using SW macro
I think this is little bit over my head, but I'm willing to learn
Looking for some tutorials, code examples or anything to get me started
Hi
We offer a SolidWorks add-on that can do that "out-of-the-box". Take a look at ToolWorks ERP-Link
Download a trial from
This is all pretty but it is way too complicated for what I need.
I have existing DB +/-40K parts which can't be modified, all I'm looking for is macro that would take configuration name query it against the DB and fill the blanks inside custom properties
Here is a code fragment which gets the description of a part from a SQL database (we use it to ensure the part desciptions match between Solidworks & the database)
You need to have the Microsoft ActiveX Data Objects library selected for it to work.
Look under tools > references in the VBA editor
Private Sub getinfo Dim msg As String Dim style As String Dim SQLstr As String
Dim rsta As New ADODB.Recordset Dim conn As New ADODB.Connection
Set conn = New ADODB.Connection Set rsta = New ADODB.Recordset conn.ConnectionString = "Provider=SQLOLEDB.1;Password=******;" & _ "Persist Security Info=false;User ID=UserID;" & _ "Initial Catalog=ALLIANCE_ENG;Data Source=FINN;" On Error GoTo ErrHandler: conn.Open On Error GoTo 0
rsta.Open "SELECT DESCTEXT FROM Partmaster WHERE PARTNUMBER='" & Trim(Partno) & "'", conn
If rsta.EOF = False Then Description = CStr(rsta.Fields(0).value)
Else msg = "Part Not Found in Alliance Partmaster Database " style = vbExclamation MsgBox msg, style, title End If rsta.Close Set rsta = Nothing conn.Close Set conn = Nothing
ErrHandler: 'clean up If conn.State = adStateOpen Then conn.Close End If
Set conn = Nothing
If Err 0 Then MsgBox Err.Source & "-->" & Err.Description, , "Error" End If End Sub
Have something to add? Share your thoughts — no account required.
Ask the community — no account required