Welcome Guest Search | Active Topics | Members | Log In | Register

Bulk Product Upload Options
Tasha123
Posted: Tuesday, July 22, 2008 9:47:07 AM
Rank: Member

Joined: 7/22/2008
Posts: 11
Location: South Africa
Is there a bulk product upload available or is it something that I will have to code and add in?
D2Admin
Posted: Wednesday, July 23, 2008 10:37:43 AM

Rank: Administration

Joined: 9/6/2007
Posts: 152
Hi, no bulk upload included as peoples data would vary too widely. If i were doing it, i'd do it at the SQL side of it and not the web app.

Paul
Tasha123
Posted: Monday, July 28, 2008 6:34:03 AM
Rank: Member

Joined: 7/22/2008
Posts: 11
Location: South Africa
I have started with it all it will be is a an exel spreadsheet that goes into the SQL DB I created a dataset this is my code behind file:
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Partial Class UploadProducts
Inherits System.Web.UI.Page

Protected Sub ButtonUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonUpload.Click
PanelUpload.Visible = True
PanelView.Visible = False
PanelImport.Visible = False
End Sub


Protected Function ExcelConnection() As OleDbCommand

' Connect to the Excel Spreadsheet
Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("~/ExcelImport.xls") & ";" & _
"Extended Properties=Excel 8.0;"

' create your excel connection object using the connection string
Dim objXConn As New OleDbConnection(xConnStr)
objXConn.Open()

' use a SQL Select command to retrieve the data from the Excel Spreadsheet
' the "table name" is the name of the worksheet within the spreadsheet
' in this case, the worksheet name is "Members" and is coded as: [Members$]
Dim objCommand As New OleDbCommand("SELECT * FROM [Products$]", objXConn)
Return objCommand
'the products$ is the worksheet name in excel not the workbook
End Function
Protected Sub ButtonView_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles ButtonView.Click
PanelUpload.Visible = False
PanelView.Visible = True
PanelImport.Visible = False

' Create a new Adapter
Dim objDataAdapter As New OleDbDataAdapter()

' retrieve the Select command for the Spreadsheet
objDataAdapter.SelectCommand = ExcelConnection()

' Create a DataSet
Dim objDataSet As New DataSet()
' Populate the DataSet with the spreadsheet worksheet data
objDataAdapter.Fill(objDataSet)

' Bind the data to the GridView
GridViewExcel.DataSource = objDataSet.Tables(0).DefaultView
GridViewExcel.DataBind()

End Sub

Protected Sub ButtonImport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonImport.Click
PanelUpload.Visible = False
PanelView.Visible = False
PanelView.Visible = True
labelImport.Text = "" ' resert to blank
' retrieve the Select Command for the worksheet data
Dim objCommand As New OleDbCommand()
objCommand = ExcelConnection()

' create a DataReader
Dim reader As OleDbDataReader
reader = objCommand.ExecuteReader()


Dim counter As Integer = 0 ' used for testing your import in smaller increments

While reader.Read()
counter = counter + 1 ' counter to exit early for testing...

' set default values for loop
Dim D2ProductID As String = Convert.ToString(reader("ProductID"))
Dim D2ProductName As String = Convert.ToString(reader("ProductName"))
Dim D2ProductShortDescrip As String = Convert.ToString(reader("ProductShortDescrip"))
Dim D2ProductLongDescrip As String = Convert.ToString(reader("ProductLongDescrip"))
Dim D2ProductPrice As String = Convert.ToString(reader("ProductPrice"))
Dim D2ProductStockLevel As String = Convert.ToString(reader("ProductStockLevel"))
Dim D2ProductActive As String = Convert.ToString(reader("ProductActive"))
Dim D2ProductShipCode As String = Convert.ToString(reader("ProductShipCode"))
Dim D2ProductSpecial As String = Convert.ToString(reader("ProductSpecial"))
Dim D2ProductSortOrder As String = Convert.ToString(reader("ProductSortOrder"))
Dim D2ProductCatID As String = Convert.ToString(reader("ProductCatID"))
Dim D2ProductWeight As String = Convert.ToString(reader("ProductWeight"))
Dim D2ProductImage1 As String = Convert.ToString(reader("ProductImage1"))
Dim D2ProductImage2 As String = Convert.ToString(reader("ProductImage2"))
Dim D2ProductImage3 As String = Convert.ToString(reader("ProductImage3"))
Dim D2ProductImage4 As String = Convert.ToString(reader("ProductImage4"))
Dim D2TaxExempt As String = Convert.ToString(reader("TaxExempt"))
Dim D2EstimatedShipping As String = Convert.ToString(reader("EstimatedShipping"))
Dim D2AllowReviews As String = Convert.ToString(reader("AllowReviews"))
Dim D2IsDownload As String = Convert.ToString(reader("IsDownload"))
Dim D2DownloadPath As String = Convert.ToString(reader("DownloadPath"))
Dim D2DownloadSize As String = Convert.ToString(reader("DownloadSize"))
Dim D2DownloadCap As String = Convert.ToString(reader("DownloadCap"))
Dim D2DownloadGUID As String = Convert.ToString(reader("DownloadGUID"))
Dim D2SoftwareVersion As String = Convert.ToString(reader("SoftwareVersion"))
Dim D2DownloadBinary As String = Convert.ToString(reader("DownloadBinary"))
Dim D2FileType As String = Convert.ToString(reader("FileType"))
Dim D2FileName As String = Convert.ToString(reader("FileName"))
Dim D2DownloadExpiry As String = Convert.ToString(reader("DownloadExpiry"))
Dim D2DateAdded As String = Convert.ToString(reader("DateAdded"))
Dim D2ProductCode As String = Convert.ToString(reader("ProductCode"))
Dim D2Manufacturer As String = Convert.ToString(reader("Manufacturer"))
Dim D2CatID2 As String = Convert.ToString(reader("CatID2"))
Dim D2PreviousPrice As String = Convert.ToString(reader("PreviousPrice"))
Dim D2ProductArea As String = Convert.ToString(reader("ProductArea"))



End While
reader.Close()


End Sub

Protected Sub ButtonUploadFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonUploadFile.Click

If FileUploadExcel.HasFile Then
Try
' alter path for your project
FileUploadExcel.SaveAs(Server.MapPath("~/ExcelImport.xls"))
LabelUpload.Text = "Upload File Name: " & _
FileUploadExcel.PostedFile.FileName & "<br>" & _
"Type: " & _
FileUploadExcel.PostedFile.ContentType & _
" File Size: " & _
FileUploadExcel.PostedFile.ContentLength & " kb<br>"
Catch ex As Exception
LabelUpload.Text = "Error: " & ex.Message.ToString
End Try
Else
LabelUpload.Text = "Please select a file to upload."
End If

End Sub


Protected Function ImportIntoProducts(ByVal D2ProductArea As String, ByVal D2ProductName As String, _
ByVal D2ProductShortDescrip As String, ByVal D2ProductLongDescrip As String, ByVal D2ProductPrice As String, ByVal D2ProductStockLevel As String, ByVal D2ProductActive As String, ByVal D2ProductShipCode As String, ByVal D2ProductSpecial As String, ByVal D2ProductSortOrder As String, ByVal D2ProductCatID As String, ByVal D2ProductWeight As String, ByVal D2ProductImage1 As String, ByVal D2ProductImage2 As String, ByVal D2ProductImage3 As String, ByVal D2ProductImage4 As String, ByVal D2TaxExempt As String, ByVal D2EstimatedShipping As String, ByVal D2AllowReviews As String, ByVal D2IsDownload As String, ByVal D2DownloadPath As String, ByVal D2DownloadSize As String, ByVal D2DownloadCap As String, ByVal D2DownloadGUID As String, ByVal D2SoftwareVersion As String, ByVal D2DownloadBinary As String, ByVal D2FileType As String, ByVal D2FileName As String, ByVal D2DownloadExpiry As String, ByVal D2DateAdded As String, ByVal D2ProductCode As String, _
ByVal D2Manufacturer As String, ByVal D2CatID2 As String, ByVal D2PreviousPrice As String, ByVal D2ProductID As Integer) As Integer
D2ProductID = Left(D2ProductID, 100)
D2ProductName = Left(D2ProductName, 100)
D2ProductShortDescrip = Left(D2ProductShortDescrip, 100)
D2ProductLongDescrip = Left(D2ProductLongDescrip, 200)
D2ProductPrice = Left(D2ProductPrice, 100)
D2ProductStockLevel = Left(D2ProductStockLevel, 100)
D2ProductActive = Left(D2ProductActive, 100)
D2ProductShipCode = Left(D2ProductShipCode, 100)
D2ProductSpecial = Left(D2ProductSpecial, 100)
D2ProductSortOrder = Left(D2ProductSortOrder, 100)
D2ProductCatID = Left(D2ProductCatID, 100)
D2ProductWeight = Left(D2ProductWeight, 100)
D2ProductImage1 = Left(D2ProductImage1, 100)
D2ProductImage2 = Left(D2ProductImage2, 100)
D2ProductImage3 = Left(D2ProductImage3, 100)
D2ProductImage4 = Left(D2ProductImage4, 100)
D2TaxExempt = Left(D2TaxExempt, 100)
D2EstimatedShipping = Left(D2EstimatedShipping, 100)
D2AllowReviews = Left(D2AllowReviews, 100)
D2IsDownload = Left(D2IsDownload, 100)
D2DownloadPath = Left(D2DownloadPath, 100)
D2DownloadSize = Left(D2DownloadSize, 100)
D2DownloadCap = Left(D2DownloadCap, 100)
D2DownloadGUID = Left(D2DownloadGUID, 100)
D2SoftwareVersion = Left(D2SoftwareVersion, 100)
D2DownloadBinary = Left(D2DownloadBinary, 100)
D2FileType = Left(D2FileType, 100)
D2FileName = Left(D2FileName, 100)
D2DownloadExpiry = Left(D2DownloadExpiry, 100)
D2DateAdded = Left(D2DateAdded, 100)
D2ProductCode = Left(D2ProductCode, 100)
D2Manufacturer = Left(D2Manufacturer, 100)
D2CatID2 = Left(D2CatID2, 100)
D2PreviousPrice = Left(D2PreviousPrice, 100)
D2ProductArea = Left(D2ProductArea, 100)

Dim ProductID As Integer = 0
Try
Dim D2Adapter As New ProductImpDataSetTableAdapters.SLProductsTableAdapter
Dim SLProductsDataTable As ProductImpDataSet.SLProductsDataTable = Nothing
SLProductsDataTable = D2Adapter.GetProductsData
If Not SLProductsDataTable Is Nothing Then
If SLProductsDataTable.Rows.Count > 0 Then
If Not SLProductsDataTable(0).D2ProductID Then
D2ProductID = SLProductsDataTable(0).D2ProductID
LabelImport.Text& = "<font color=blue>Product Found, Not Imported:" & _ "ID: " & D2ProductID & .</font><br>"

End If

End If
End If
If D2ProductID = 0 Then
D2ProductID = Convert.ToInt32(D2Adapter.InsertProductsQuery(loadGUID, D2SoftwareVersion as String, D2DownloadBinary()As Byte, D2FileType, D2FileName, D2DownloadExpiry, D2DateAdded, D2ProductCode, D2Manufacturer, D2CatID2, D2PreviousPrice))
End If

Return D2ProductID

Catch ex As Exception
LabelImport.Text &= "<font color=red>" & ex.ToString & "</font><br/>"
Return 0


End Try
End Function
End Class





I am how ever having problems with it - no spurise there LOL
The big erro I am getting is:
Error 39 Argument not specified for parameter 'D2AllowReviews' of 'Public Overridable Overloads Function InsertProductsQuery(D2ProductName As String,
ANY IDEAS??
D2Admin
Posted: Monday, July 28, 2008 11:36:57 AM

Rank: Administration

Joined: 9/6/2007
Posts: 152
Hi, i cant see the code there for the function thats throwing the error: D2Adapter.InsertProductsQuery. Looks like its got more parameters defined than you are passing into it. Would you be able to zip and send the code to me along with an example of the the spreadsheet you are trying to import from? Paul
Tasha123
Posted: Monday, July 28, 2008 11:38:31 AM
Rank: Member

Joined: 7/22/2008
Posts: 11
Location: South Africa
Consider it done :)
D2Admin
Posted: Friday, August 01, 2008 10:28:17 AM

Rank: Administration

Joined: 9/6/2007
Posts: 152
Havent forgotton you here! I'm coding a standard build in way of importing based on the spreadsheet you provided. This will be included as part of the next release.

Paul
Tasha123
Posted: Sunday, August 03, 2008 12:34:17 PM
Rank: Member

Joined: 7/22/2008
Posts: 11
Location: South Africa
I am still struggling with this which seems to be turning into a three headed monsterBrick wall Brick wall Brick wall Eh?

VB seems to have a problem with this part

End If
If D2ProductID = 0 Then
D2ProductID = _
Convert.ToInt64(D2Adapter.InsertProductsQuery(D2ProductName As String, D2ProductShortDescrip As String, D2ProductLongDescrip As String, D2ProductPrice As System.Nullable(Of Decimal), D2ProductStockLevel As System.Nullable(Of Integer), D2ProductActive As Boolean, D2ProductShipCode As System.Nullable(Of Integer), D2ProductSpecial As Boolean, D2ProductSortOrder As Integer, D2ProductCatID As System.Nullable(Of Integer), D2ProductWeight As Integer, D2ProductImage1 As String, D2ProductImage2 As String, D2ProductImage3 As String, D2ProductImage4 As String, D2TaxExempt As Boolean, D2EstimatedShipping As Decimal, D2AllowReviews As Boolean, D2IsDownload As Boolean, D2DownloadPath As String, D2DownloadSize As System.Nullable(Of Integer), D2DownloadCap As Integer, D2DownloadGUID As String, D2SoftwareVersion As String, D2DownloadBinary() As Byte, D2FileType As String, D2FileName As String, D2DownloadExpiry As Integer, D2DateAdded As Date, D2ProductCode As String, D2Manufacturer As String, D2CatID2 As System.Nullable(Of Integer), D2PreviousPrice As System.Nullable(Of Decimal), D2ProductArea As String, D2ProductID As Integer) As Integer
LabelImport.Text &= "<font color=green>Products Imported " & " ID:" & D2ProductID & ".</font> <br>"


The error is that Argument not specified for parameter but it is usually only for the first 5 so I thought (I am awfully clever here) I will just delete the first five! No luck there it just move to the next five?

Is the string to long??



Even though the error seems to think the argument is not specified I believe it is - maybe I am wrong there?

I have a dataset with a query called InsertProductsQuery and all the fields are the same EXCACTLY I also have :

set default values for loop
Dim D2ProductID As Integer = Convert.ToString(reader("ProductID"))
Dim D2ProductName As String = Convert.ToString(reader("ProductName"))
Dim D2ProductShortDescrip As String = Convert.ToString(reader("ProductShortDescrip"))
Dim D2ProductLongDescrip As String = Convert.ToString(reader("ProductLongDescrip"))
Dim D2ProductPrice As System.Nullable(Of Decimal) = Convert.ToString(reader("ProductPrice"))
Dim D2ProductStockLevel As System.Nullable(Of Integer) = Convert.ToString(reader("ProductStockLevel"))
Dim D2ProductActive As Boolean = Convert.ToString(reader("ProductActive"))
Dim D2ProductShipCode As System.Nullable(Of Integer) = Convert.ToString(reader("ProductShipCode"))
Dim D2ProductSpecial As Boolean = Convert.ToString(reader("ProductSpecial"))
Dim D2ProductSortOrder As Integer = Convert.ToString(reader("ProductSortOrder"))
Dim D2ProductCatID As System.Nullable(Of Integer) = Convert.ToString(reader("ProductCatID"))
Dim D2ProductWeight As Integer = Convert.ToString(reader("ProductWeight"))
Dim D2ProductImage1 As String = Convert.ToString(reader("ProductImage1")) GOES ON ON AND ON..................................but everything is in there

and then again

Protected Function ImportIntoProducts(ByVal D2ProductArea As String, ByVal D2ProductName As String, _
ByVal D2ProductShortDescrip As String, ByVal D2ProductLongDescrip As String, ByVal D2ProductPrice As String, ByVal D2ProductStockLevel As String, ByVal D2ProductActive As String, ByVal D2ProductShipCode As String, ByVal D2ProductSpecial As String, ByVal D2ProductSortOrder As String, ByVal D2ProductCatID As String, ByVal D2ProductWeight As String, ByVal D2ProductImage1 As String, ByVal D2ProductImage2 As String, ByVal D2ProductImage3 As String, ByVal D2ProductImage4 As String, ByVal D2TaxExempt As String, ByVal D2EstimatedShipping As String, ByVal D2AllowReviews As String, ByVal D2IsDownload As String, ByVal D2DownloadPath As String, ByVal D2DownloadSize As String, ByVal D2DownloadCap As String, ByVal D2DownloadGUID As String, ByVal D2SoftwareVersion As String, ByVal D2DownloadBinary As String, ByVal D2FileType As String, ByVal D2FileName As String, ByVal D2DownloadExpiry As String, ByVal D2DateAdded As String, ByVal D2ProductCode As String, _
ByVal D2Manufacturer As String, ByVal D2CatID2 As String, ByVal D2PreviousPrice As String, ByVal D2ProductID As Integer) As Integer
D2ProductID = Left(D2ProductID, 100)
D2ProductName = Left(D2ProductName, 100)
D2ProductShortDescrip = Left(D2ProductShortDescrip, 100)



WHERE AM I GOING WRONG WHAT AM I MISSING??
D2Admin
Posted: Monday, August 04, 2008 7:51:10 AM

Rank: Administration

Joined: 9/6/2007
Posts: 152
I'm currently in the process of knocking up something similar but for your code:

Code:
End If
If D2ProductID = 0 Then
D2ProductID = _
Convert.ToInt64(D2Adapter.InsertProductsQuery(D2ProductName As String, D2ProductShortDescrip As String, D2ProductLongDescrip As String, D2ProductPrice As System.Nullable(Of Decimal), D2ProductStockLevel As System.Nullable(Of Integer), D2ProductActive As Boolean, D2ProductShipCode As System.Nullable(Of Integer), D2ProductSpecial As Boolean, D2ProductSortOrder As Integer, D2ProductCatID As System.Nullable(Of Integer), D2ProductWeight As Integer, D2ProductImage1 As String, D2ProductImage2 As String, D2ProductImage3 As String, D2ProductImage4 As String, D2TaxExempt As Boolean, D2EstimatedShipping As Decimal, D2AllowReviews As Boolean, D2IsDownload As Boolean, D2DownloadPath As String, D2DownloadSize As System.Nullable(Of Integer), D2DownloadCap As Integer, D2DownloadGUID As String, D2SoftwareVersion As String, D2DownloadBinary() As Byte, D2FileType As String, D2FileName As String, D2DownloadExpiry As Integer, D2DateAdded As Date, D2ProductCode As String, D2Manufacturer As String, D2CatID2 As System.Nullable(Of Integer), D2PreviousPrice As System.Nullable(Of Decimal), D2ProductArea As String, D2ProductID As Integer) As Integer
LabelImport.Text &= "<font color=green>Products Imported " & " ID:" & D2ProductID & ".</font> <br>"


That doesnt look right. Dont see what you are trying to do there. Its trying to grab an int value from the definition of a function there, instead of giving the parameters its trying to define them in the function call?

Shouldnt it be something like: D2ProductID = (D2Adapter.InsertProductsQuery("Audi A4","An Audi motor","blah blah"....etc))

But anyhow, i'll produce my code and post it here.

Paul
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

SoClean Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1 (NET v2.0) - 9/1/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.