I am trying to write a utility that will be used once a month to import new products to our Products database,
productsTemp contains the new products to add, products is the main table they are being added to, the steps I have working are as follows
1) Read the entire contents of productsTemp into a dataset
2) Loop through the dataset & for every entry found insert a new record into the products table, retrieve the new productID for the next stage:
Rough outline of how it works so far
myDataset populated via SP from tempProducts
dim i as integer = 0
dim recordcount = myDataset.Tables(0).Rows.Count
Do While i < recordCount
'Code to insert the record here
'retrieve the productID
dim newProductID = Value Retrieved From SP
'Need to loop through the comma seperated values & insert into product attributes table
i += 1
loop
The next stage is that we have a column in the productsTemp table called "attributelist" containing a comma seperated list of attributeID's with a maximum of around 6 entries, these need adding to our "prodAttributes" table something like this
productID AttributeID
1 2
1 3
1 5
2 2
2 8
etc
I have split the attributes from the temp table into an array as follows
Dim attributelist = myDataset.Tables(0).Rows(i)("AttributeList")
Dim attributeArray As Array
attributeArray = attributelist.Split(",")
But now need to loop through the array to insert into the prodAttributes table, but I'm totally stuck! Any pointers gratefully received.
Thanks
ossie
Are you having troubles looping through the array or inserting data to the database. Here is how to loop through the array.
Dim i as Integer
for i = 0 to attributeArray.Length - 1
InsertToProdAttributes(attributeArray(i))
next
Perfect, Thank you very much
ossie
0 comments:
Post a Comment