Solved Multiple NULL Terminiated strings combined into one string

forum.sourcecode (2000-2005) & forum.td.sourcecode (2005-2010)
Unknown user

Multiple NULL Terminiated strings combined into one string

Post by Unknown user » 09 Nov 2006, 03:19

 Posted by:  newsgroup.guptworlwide.com 

Hi All,

How do I create a string in Centura (TD 2005.1), that will be passed to a
Windows API function (SQLConfigDataSource) that is made up of multiple null
terminated strings

e.g. if I want to send a DSN and Database in the string it would be
"DSN=test\0Database=test\0\0"

Jim McNamara

Re: Multiple NULL Terminiated strings combined into one string

Post by Jim McNamara » 09 Nov 2006, 16:43

 Posted by:  Jim McNamara 

How does the target function expect to receive it? I'd guess that you push
the data into far memory and pass the pointer. See cstructl.apl and sample
apps for same.

Christian Astor

Re: Multiple NULL Terminiated strings combined into one string

Post by Christian Astor » 09 Nov 2006, 21:00

 Posted by:  Christian ASTOR 


CStructPutString()

Keith Cumberbatch

Re: Multiple NULL Terminiated strings combined into one string

Post by Keith Cumberbatch » 09 Nov 2006, 23:23

 Posted by:  Keith Cumberbatch 

Which was what I thought - I'm using CStructPutString, but it's not working,
I give this another try tomorrow

thanks.

Keith Cumberbatch

Re: Multiple NULL Terminiated strings combined into one string

Post by Keith Cumberbatch » 09 Nov 2006, 23:27

 Posted by:  Keith Cumberbatch 

I've been using CStructPutString, but it appears I'm not using it correctly.
I'll try again tomorrow and if that does not work, I'll just use a C DLL to
accomplish what I want.

thanks

Christian Astor

Re: Multiple NULL Terminiated strings combined into one string

Post by Christian Astor » 10 Nov 2006, 09:25

 Posted by:  Christian ASTOR 

Code: Select all

!!CB!! 174
Call SalStrSetBufferLength(sBuffer, 1024 )
Set nLength = 0
Set sDSN = "DSN=TEST_EXCEL"
Call CStructPutString(sBuffer, nLength, SalStrLength(sDSN), sDSN)
Set nLength = nLength + SalStrLength(sDSN) + 1
Set sDescription = "Description=New Excel Data Source"
Call CStructPutString(sBuffer, nLength, SalStrLength(sDescription), sDescription )
Set nLength = nLength + SalStrLength(sDescription) + 1
... etc...

Jim McNamara

Re: Multiple NULL Terminiated strings combined into one string

Post by Jim McNamara » 10 Nov 2006, 15:33

 Posted by:  Jim McNamara 

Call SalStrSetBufferLength(sBuffer, 1024 ) is the key!

Keith Cumberbatch

Re: Multiple NULL Terminiated strings combined into one string

Post by Keith Cumberbatch » 11 Nov 2006, 19:14

 Posted by:  Keith Cumberbatch 

Thanks Christian,

This does not look very different to what I was doing ;-> When I reach work
on Monday I'll compare what you have to what I was writing.
For what I can remember, here is what I was doing

Code: Select all

Call SalStrSetBufferSize( szAttr, 50 )
Call CStructPutString( szAttr, 0, 12, "DSN=SBDEVTST" )
Call CStructPutString( szAttr, 14, 13, "Database=test" )
It looks like the beginning position in my second PutString is different to
yours.

Keith Cumberbatch

Re: Multiple NULL Terminiated strings combined into one string

Post by Keith Cumberbatch » 13 Nov 2006, 23:58

 Posted by:  Keith Cumberbatch 

Problem solved ;->

The issue was not the code but the second parameter than was being passed to
SQLConfigDataSource, that tells it what to do. The Gupta driver does not
allow the ODBC_CONFIG defines to modify the DSN entries, you have to use one
of the ODBC_ADD defines to add or modify the DSN entry.

Return to “td.sourcecode”

Who is online

Users browsing this forum: [Ccbot] and 0 guests