Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    2

    Unanswered: binary data insert fails using dblib

    who still uses the old dblib can help me?
    thanks in advance:


    1.create table & procedure in db:
    test_table(uniqueidentifier a,varbinary50 b)
    CREATE PROCEDURE insert_table
    @b_in varbinary
    AS
    insert into test_table(b) values (@b_in)
    GO

    2.write program use dblib:
    wchar_t str[120]=L"ABC";
    dbrpcparam(dbproc[i], "@b_in", (BYTE)NULL, SQLVARBINARY,
    -1, 6, &str)

    3.I can find the program executed successfully,but only 1 Byte is inserted:
    a b
    -----------------------------------------------
    199D71BE-327A-4BC1-AEC8-ACB0C96076CA 0x41



    how to insert the whole string into the database?
    Last edited by lippman; 07-30-04 at 13:18. Reason: try

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    See if you can spot the difference in the code below (tsk...the answer is there...):

    declare @i varbinary
    set @i = 0xffffffff
    select @i, datalength(@i)
    go
    declare @i varbinary(10)
    set @i = 0xffffffff
    select @i, datalength(@i)
    go
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Jul 2004
    Posts
    2
    Thanks! I have made a serious mistake *_*

Posting Permissions

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