Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65

    Unanswered: Statement could not be prepared

    Hi!

    If I'm running a DTS with 2 connections(flat file source and SQL table destination) and a Data Driven Query Task, and then I get an error message saying "Stataments sould not be prepared. Line 2: Invalid syntax near "."

    Which code should I look for the error? The message says Line 2 but i don't know where to look.

    Thanks.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Did you write the sql or did you let a wizard build it. Sounds like the former.

    There's a problem with your sql syntax...post the code.
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65
    Most of the codes were generated through the wizard. But I modified some of them to meet my requirements. Here's what I have in the Dara Driven Query Task:

    Source tab: No query, I used a wizard
    Bindings: I selected an existing table(Mailout DB)
    The fields are as follows: MID,IIN,ITN2(PK),ITN,ITN3,Gender,LANG,Title,Name,A ddress,Apt,City,Stream,Prov,POstCode

    Transformations:
    ' Copy each source column to the destination column
    Function Main()

    strMth = MonthName(month(date))
    Select Case strMth
    Case "January"
    mth = 1
    Case "February"
    mth = 1
    Case "March"
    mth = 1
    Case "April"
    mth = 1
    Case "May"
    mth = 1
    Case "June"
    mth = 1
    Case "July"
    mth = 1
    Case "August"
    mth = 2
    Case "September"
    mth = 2
    Case "October"
    mth = 2
    Case "November"
    mth = 2
    Case "December"
    mth = 2
    End Select

    DTSDestination("MID") = DTSSource("Col001")
    DTSDestination("IIN") = mth & DTSSource("Col003")
    DTSDestination("ITN2") = DTSSource("Col004")
    DTSDestination("ITN") = DTSSource("Col005")
    DTSDestination("ITN3") = DTSSource("Col006")
    DTSDestination("GENDER") = DTSSource("Col007")
    DTSDestination("LANG") = DTSSource("Col008")
    DTSDestination("TITLE") = DTSSource("Col009")
    DTSDestination("NAME") = DTSSource("Col010")
    DTSDestination("ADDRESS") = DTSSource("Col011")
    DTSDestination("APT") = DTSSource("Col012")
    DTSDestination("CITY") = DTSSource("Col013")
    DTSDestination("STREAM") = DTSSource("Col014")
    DTSDestination("PROV") = DTSSource("Col015")
    DTSDestination("POSTCODE") = DTSSource("Col016")

    If DTSLookups("Count_ITN2").Execute (DTSSource("Col004")) = 0 Then
    Main = DTSTransformstat_InsertQuery
    End If
    End Function

    Queries tab: I only have an insert query
    INSERT INTO [Mailout DB]
    VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

    Lookups: I have a lookup called COUNT_ITN2
    SELECT COUNT(*) as Expr1
    FROM [Mailout DB]
    WHERE (ITN2=?)

  4. #4
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65
    Hi!

    Can anyone please help me debug this problem?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •