SQl Server Native client bcp_bind datetime

  • Hi,

    I am not able to insert datetime values in sql server 2008 r2 database table from a data file using bcp_sendrow api.

    My question is:

    What should be the program variable type while binding the datetime datatype? Can it be a character array? Is odbc api implicitly capable of converting the character type to datetime? Or SQL Server does that. If not, please suggest a C type I should use.

    Right now the function call I am using is:

    bcp_bind(hdbc1, (LPCBYTE)&dtime, 0, -1, (LPCBYTE) "", 1, SQLDATETIME, 5)

    where, dttime is a character array containing datetime value. I also tried using a TIMESTAMP_STRUCT type.

    I am not getting any error but the values getting inserted in the table are NULL.

    The datetime formats I tried:

    mm/dd/yyyy hh:mm:ss.nnn

    mm/dd/yyyy

    yyyy-dd-mm hh:mm:ss.nnn

    yyyy-dd-mm hh:mm:ss

    For all cases, NULL values are getting inserted in the table. Any pointers would be really helpful.

    Thanks,

    Abhijeet Gaikwad

  • I am in urgent need of a solution to the above mentioned issue. Can anyone please help me out as soon as possible?

  • using bcp_sendrow api

    If bcp_sendrow api is only available option to you. I would suggest you to refer following:

    bcp_sendrow

    http://msdn.microsoft.com/en-us/library/ms131652.aspx

    bcp_bind

    http://msdn.microsoft.com/en-us/library/ms131401.aspx

  • Thanks for your reply.

    These links aren't much a help for binding datetime column.

    Have you used it before in any of your use cases? That would help me.

    Thanks,

    Abhijeet Gaikwad

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply