Re: Problem with 64-bit ODBC code and SQLConnect and SQLWCHAR



Hi

SQL Server 2005 CTP questions to the community newsgroups:
http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us

--
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@xxxxxxxxxxxx

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Nick Palmer" <nick@xxxxxxxxxxx> wrote in message
news:11i480ff7qiikf9@xxxxxxxxxxxxxxxxxxxxx
> Hi all,
>
> I'm trying to test some 64-bit ODBC stuff and I'm running into a slight
> problem. First, my configuration.
>
> Windows XP x64
> VS.Net 2005 Beta 2
> SQL Server 2005 CTP
>
> So, I have built and tested other 64 bit apps so I know that things are
> all
> working, but now I'm trying to test ODBC and I'm running into a problem.
> I
> have the following code :
>
> SQLCHAR Database[MAXBUFLEN]; // = "Cloud";
> SQLCHAR User[MAXBUFLEN]; // = "fred";
> SQLCHAR Pass[MAXBUFLEN]; // = "me";
>
> sprintf ((char *)Database, "%s", "Cloud");
> sprintf ((char *)User, "%s", "fred");
> sprintf ((char *)Pass, "%s", "me");
>
> retcode = SQLConnect(hdbc1, Database, SQL_NTS,
> User, SQL_NTS, Pass, SQL_NTS);
>
> If I execute this code as part of a little test program on my 32 bit box,
> it
> connects just fine. Now, to get this code to compile on the 64-bit box, I
> have to cast the string variable with (SQLWCHAR *) like this.
>
> retcode = SQLConnect(hdbc1, (SQLWCHAR *)Database, SQL_NTS,
> (SQLWCHAR *)User, SQL_NTS, (SQLWCHAR *)Pass, SQL_NTS);
>
> So it compiles, but when I run it, I get an error back. If I take a look
> at what (SQLWCHAR *)Database produces, its some unreadable junk. If I
> turn
> on ODBC logging and then after the SQLConnect call take a look at the log,
> where I should see the database for instance, I see just random
> characters.
>
> So, what gives ? Do I have to do something special when working with
> SQLWCHAR ?
>
> Thanks for any help anyone can give me.
>
> Nick
>
>


.



Relevant Pages

  • Re: Question about SQL Server 2005
    ... >> Mike Epprecht, Microsoft SQL Server MVP ... >> MVP Program: http://www.microsoft.com/mvp ... >> Blog: http://www.msmvps.com/epprecht/ ...
    (microsoft.public.sqlserver.setup)
  • Re: Insert picture
    ... Mike Epprecht, Microsoft SQL Server MVP ... MVP Program: http://www.microsoft.com/mvp ... > Access allows to insert manually an image into OLE Object type field very ...
    (microsoft.public.sqlserver.tools)
  • Re: Image save into folder
    ... Mike Epprecht, Microsoft SQL Server MVP ... >> Mike Epprecht, Microsoft SQL Server MVP ... >> Zurich, Switzerland ... >> MVP Program: http://www.microsoft.com/mvp ...
    (microsoft.public.sqlserver.clients)
  • Re: Setup steps to install SQL Server 2000 and maximize performance
    ... Mike Epprecht, Microsoft SQL Server MVP ... MVP Program: http://www.microsoft.com/mvp ... Blog: http://www.msmvps.com/epprecht/ ...
    (microsoft.public.sqlserver.setup)
  • Re: SQL in a standalone domain
    ... Mike Epprecht, Microsoft SQL Server MVP ... MVP Program: http://www.microsoft.com/mvp ... Blog: http://www.msmvps.com/epprecht/ ...
    (microsoft.public.sqlserver.odbc)