Results 1 to 9 of 9

Thread: [RESOLVED] ODBC SQL Parameters

  1. #1

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Resolved [RESOLVED] ODBC SQL Parameters

    Hello,

    im need to write data to a 3rd party database in which i cannot rename columns etc...
    many of the column names contain a "-" in them eg: prod-name

    im trying to contruct a parameterised query but im having problems
    VB Code:
    1. "INSERT INTO Products (""prod-name"") VALUES (?)"
    im using the double quotes so the database will accept the "-"
    VB Code:
    1. Dim l_sqlCmd = l_sqlConnection.CreateCommand()
    2.  
    3. l_sqlCmd.Parameters.Add("@prod-name", "My Product")
    4.  
    5. l_sqlCmd.Prepare()
    6. l_sqlCmd.ExecuteNonQuery()

    will the parameters accept the parameter name as in the SQL statement there are the double quotes
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  2. #2
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: ODBC SQL Parameters

    Can you use "[" and "]" instead of the double quotes, or are you stuck with the query as-is?

  3. #3

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: ODBC SQL Parameters

    im stuck with it as it. The database is a progress one so its very very very picky about what you can do.

    im just wondering will it ignore the inner quotation marks
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  4. #4
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: ODBC SQL Parameters

    I don't think so. I think it's still going to try and calculate the column names. You aren't able to do something like this in your code to INSERT?

    "INSERT INTO Products ([prod-name], [prod-desc]) VALUES (@prodname, @proddesc)"

    l_sqlCmd.Parameters.Add("@prodname", "My Product")
    l_sqlCmd.Parameters.Add("@proddesc", "My Product Description")

  5. #5

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: ODBC SQL Parameters

    no it doesnt recognise the [] it gives a syntax error.
    it worked for the double quotes """" except for when trying to insert a date
    hmmmm
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  6. #6
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: ODBC SQL Parameters

    Hmmmm; what kind of database is the 3rd party using?

    (I ran the statement in my analyzer and it worked for me)

  7. #7

    Thread Starter
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: ODBC SQL Parameters

    its a Progress Database....
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  8. #8
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: ODBC SQL Parameters

    Try using single quotes around the string you will send

    " ' INSERT INTO Products ("prod-name") VALUES (?)' "
    or

    "INSERT INTO Products ('prod-name' ) VALUES (?)"

    a lot of SQL interpreters use single quotes for string that shoudn't be proccessed before interpreting.

    fiddle around a bit maybe you wil get lucky.

    Groeten Berend
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  9. #9
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: ODBC SQL Parameters

    I did some looking around about progress. From the looks of it, it handles column names with '-' as if it was just another character. In the examples, you don't need to do anything with it:

    Look under "Data Manipulation Language" --> "Inserting Rows"
    http://www.progress.com/progress/pro...oa/s89/s89.pdf

    When you give the date parameter to the statement, how are you doing it?

    I've been trying to figure out the statement, but it looks a little too pseudo to really understand why only a date wouldn't work.

Posting Permissions

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



Click Here to Expand Forum to Full Width