|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 11/06/2009 at 03:23AM PST, ID: 24877515 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: |
Public Sub ImportShopData(strRawDataFile As String)
' ****************************************************************************
' A procedure for importing daily sales data from retail shops
'
' strRawDataFile - full path and file name of raw data
'
' Will open ".TXT" file into an Excel spreadsheet,
' then read rows from the spreadsheet and insert them into a SQL Server Table via a Stored Procedure
' ****************************************************************************
On Error GoTo HandleError
Dim xlsApp As Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
'create new excel instance
Set xlsApp = New Excel.Application
'Don't open the excel application and don't show warnings
xlsApp.Visible = False
xlsApp.DisplayAlerts = False
' Try to open the text file as a "hidden" Excel spreadsheet
' File colmns will be comma-separated and 4th column contain stock codes, possibly with leading zeroes
xlsApp.Workbooks.OpenText strRawDataFile, xlMSDOS, 1, xlDelimited, 1, False, False, False, True, False, False, , Array(Array(4, 2))
Set xlsBook = ActiveWorkbook
Set xlsSheet = xlsBook.Worksheets(1)
' Here are the variables for copying data from Excel worksheet into SQL Server Table
Dim blnDataExists As Boolean
Dim intRowIndex, intColIndex As Integer
Dim strShopCode As String
Dim datSalesDate As Date
Dim strStockCode As String
Dim intSalesQnty As Integer
Dim curSalesValue As Currency
Dim strSQLString As String
blnDataExists = True
'Row 1 has a header so start reading data from spreadsheet row 2
intRowIndex = 2
intColIndex = 1
Do While blnDataExists = True
' There should be data in every column of every row
If Trim(xlsSheet.Cells(intRowIndex, 1)) <> "" Then
With xlsSheet
' Collect data from current row into my variables
' Column 1 is a line counter - we don't need it
strShopCode = Nz(.Cells(intRowIndex, 2), "")
datSalesDate = Nz(.Cells(intRowIndex, 3), Date)
strStockCode = Nz(.Cells(intRowIndex, 4), "")
intSalesQnty = Nz(.Cells(intRowIndex, 5), 0)
curSalesValue = Nz(.Cells(intRowIndex, 6), 0)
If Not (genAllBlanks(strShopCode) Or genAllBlanks(strStockCode) Or _
(intSalesQnty = 0) Or (curSalesValue = 0)) Then
' Prepare a parameter list to pass these variables into a Stored Procedure
ReDim mySPParamList(5)
Call FillSPParameter(mySPParamList(0), "@paramShopCode", adVarChar, adParamInput, strShopCode)
Call FillSPParameter(mySPParamList(1), "@paramSalesDate", adDate, adParamInput, datSalesDate)
Call FillSPParameter(mySPParamList(2), "@paramStockCode", adVarChar, adParamInput, strStockCode)
Call FillSPParameter(mySPParamList(3), "@paramSalesQnty", adInteger, adParamInput, intSalesQnty)
Call FillSPParameter(mySPParamList(4), "@paramSalesValue", adCurrency, adParamInput, curSalesValue)
' Execute the Stored Procedure to INSERT data into the SQL Server Table
Call Execute_SP_Params_NoRS("USP_InsertIntoTempShopDaySales", mySPParamList)
End If
End With
'Move on to the next row
intRowIndex = intRowIndex + 1
Else
blnDataExists = False
End If
Loop
MsgBox ("Import Process Complete")
Clean_Up:
' Close Workbook and Quit Excel
xlsBook.Close
xlsApp.Quit
Set xlsSheet = Nothing
Set xlsBook = Nothing
Set xlsApp = Nothing
Exit Sub
HandleError:
genErrorHandler Err.Number, Err.DESCRIPTION, "DB_LOGIC", "ImportShopData"
Resume Clean_Up
End Sub ' ImportShopData
|
Advertisement