Re: SQLBindParameter
From: Brannon Jones (brannonjNOSPAM_at_gmail.com)
Date: 08/19/04
- Next message: rschuchm: "RE: SQLBindParameter"
- Previous message: rschuchm: "SQLBindParameter"
- In reply to: rschuchm: "SQLBindParameter"
- Next in thread: rschuchm: "RE: SQLBindParameter"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 14:29:25 -0700
The problem is that you are using Unicode string data, and telling ODBC that
the type of data is an ANSI string. So, you get truncation after the first
character.
The fix is easy, instead of SQL_C_CHAR, use SQL_C_WCHAR. Also, for the sake
of efficiency, make sure that you really want to store the Unicode data in
the database as ANSI (SQL_VARCHAR is ANSI). And double check that the
actual type of the parameter is ANSI (varchar). If the actual type of the
parameter is Unicode (nvarchar) then you are going through an extra,
unnecessary, and possibly lossy, conversion (from Unicode -> ANSI ->
Unicode).
Let me know if you have any more questions on this.
Brannon
"rschuchm" <rschuchm@discussions.microsoft.com> wrote in message
news:4906225F-4F6C-4ECB-8483-5698F9E29E1E@microsoft.com...
> I am having trouble with SQLBindParameter when binding a CString to a
> SQL_VARCHAR; also, I am using UniCode. Only the first character of the
value
> gets passed to the stored procedure called by ExecuteSQL.
>
> m_nBufferLength=SQL_NTS;
> retcode = SQLBindParameter(hstmt,1, SQL_PARAM_INPUT_OUTPUT,
> SQL_C_CHAR,SQL_VARCHAR, 32, 0, (SQLPOINTER)((LPCTSTR)m_strVal), 32,
> &m_nBufferLength);
>
> I've also tried using
> retcode = SQLBindParameter(hstmt,1, SQL_PARAM_INPUT_OUTPUT,
> SQL_C_CHAR,SQL_VARCHAR, 32, 0, m_strVal.GetBuffer(), 32,
&m_nBufferLength);
>
> Any suggestions?
> --
> -rose
- Next message: rschuchm: "RE: SQLBindParameter"
- Previous message: rschuchm: "SQLBindParameter"
- In reply to: rschuchm: "SQLBindParameter"
- Next in thread: rschuchm: "RE: SQLBindParameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|