Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
justinparfitt
in reply to: A.Acheson

Hi,

 

Thank you for the pointing me in the correct direction.

I have moved the ExtSql(sConn, sql) to the loop as code below, and it is importing correct qty of components(on BOM showed 3 items, and sql is showing 3 items (job no and door ref), but there is no description, qty, stocknumber and partnumber. So, it looks like it is not picking up the string.  Any ideas on this one? Thanks...

 

'BOM to SQL
Dim PartNumber, Qty, StockNumber, Description As String
Dim sConn As String = String.Empty
	sConn="Provider=SQLOLEDB;Data Source=XXX;Initial Catalog=XXX;User ID=XXX;Password=XXX;Connect Timeout=30;Encrypt=True;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

	'Enter Tablename and values to insert
	'If there are less values than columns in your table, you need to specify wich value corresponds to which column
	Dim sql As String = String.Empty
	sql = "INSERT INTO InventorBOM1 (JOB_NO,PROJECT_ID,ITEM,Qty,Description,StockNumber) VALUES ('"& JOB_NO &"','"& PROJECT_ID &"','"& PartNumber &"','"& Qty &"','"& Description &"','"& StockNumber &"')"
	
Dim row As Integer = 5
row = 5
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Structured")


Dim bRow As BOMRow
bRows = oBOMView.BOMRows
'For each row in the Structured BOM, do the following
For Each bRow In bRows
'Set a reference to the primary ComponentDefinition of the row
Dim rDoc As Document
rDoc = bRow.ComponentDefinitions.Item(1).Document

Dim docPropertySet As PropertySet
docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties")

StockNumber = bRow.ItemNumber
Qty = bRow.ItemQuantity
Description = docPropertySet.Item("Description").Value
PartNumber = docPropertySet.Item("Part Number").Value


row = row + 1
ExtSql(sConn, sql)
Next
MsgBox("Command executed", MsgBoxStyle.Information, "iLogic")