Showing posts with label advance1. Show all posts
Showing posts with label advance1. Show all posts

Thursday, March 22, 2012

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?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|||Thanks! I have made a serious mistake *_*