Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DTS Conversion Problem w/ActiveX Script

Posted on 2007-12-04
6
Medium Priority
?
372 Views
Last Modified: 2013-11-30
I have the following code. The problem is that the source cell (BTN) can be either empty (NULL), be a number formatted as text, or be stored as a number. When I run the transformation, it sees any row that has a number, stored as a number, as NULL and will not import it. I have tried using CStr() around the source value, but that does not seem to help. Any ideas?
Function Main()
	If IsNull(DTSSource("BTN")) Then
	    Main = DTSTransformStat_SkipRow
	    Exit Function
	ElseIf IsNumeric(DTSSource("BTN")) Then
	    DTSDestination("BTN") = CDbl(DTSSource("BTN"))
	End If
	DTSDestination("RequestID") = DTSSource("RqstID")
	Main = DTSTransformStat_OK
End Function

Open in new window

0
Comment
Question by:dbbishop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20404861
Assuming this is a text file, please post some sample data that presents that problem.
0
 
LVL 15

Author Comment

by:dbbishop
ID: 20406107
I am importing two columns on the worksheet. The column represented as BTN is either a 10 or 13-digit number. On the worksheet, some of the colums are represented as number formatted as text, some are text (e.g. preceeded by an apostrophe "'") which is ignored by DTS, and some are actually sotred as numbers in a numeric format.

I have one file that only had about 40 rows, so I put a msgbox ahead of the If...Then...Else statement to show the value. With those that had the data in the cell in a numeric format, then MsgBox(DTSSource("BTN")) showed a value of NULL.
0
 
LVL 15

Author Comment

by:dbbishop
ID: 20406113
btw, I am importing from a sheet in an Excel workbook.
0
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 750 total points
ID: 20408370
Than this should help:
Excel Inserts Null Values
http://www.sqldts.com/254.aspx
0
 
LVL 15

Author Comment

by:dbbishop
ID: 20416073
acperkins: I tried the example they showed by using an ActiveX script and that does not appear to help with the problem. One thing is that there can be a datatype change within the first eight rows.

The user sends me data that i copy/paste into a template spreadsheet and then run a DTS package that does a return-trip process (imports the data, runs an EXECUTE SQL task to pull data from other tables, then exports the data back to another sheet in the workbook.

I've advised the user to make sure all data is formatted as text, and I've started eyeballing it before running the package (which is basically fix #1 of the article), so I will just continue to go that route, although it would be nice if the script handled the problem.

Doug
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20416663
>>I tried the example they showed by using an ActiveX script and that does not appear to help with the problem. <<
This is exactly what we use.  So if it does not work for you, than I am afraid I have no idea.

Good luck.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question