Unable to retrieve varchar(max) fields using VB6 ADO on SQL Server with ODBC 13 drivers
We have a VB6 application using ADO and needed to update the SQL Server ODBC drivers to handle TLS 1.2 compliancy. I am able to query a varchar(max) field using the original {SQL Server} driver, but any newer ODBC driver will not return varchar(max) fields (13, 11, SQL Native Client 11, 10, etc.). All the other fields field types return fine with newer drivers, except the varchar(max).
I am setting my database connection string as follows:
PROVIDER=MSDASQL;Driver={ODBC Driver 13 for SQL Server};Server=server;DATABASE=dbname;UID=user;PWD=password;DataTypeCompatibility=80;MARS Connection=True;
Then executing the ADO recordset using:
Set recordset1 = gsSQLConn.Execute(strSQL, recordsaffected, adCmdText)
The SQL is
SELECT TABLE.NOTES AS [Value] From TABLE WHERE (((TABLE.NOTES) Is Not Null) AND ((TABLE.TABLE_ID)=#####))
where ##### is a valid integer ID for the table.
The return value shows as:
2 à
and is type 200 (adVarChar).
I am at a loss on this one, and not sure why I cannot get the newer ODBC drivers to read the varchar(max) fields. I did look into the SQLGetData function, but not quite sure how to get it working for my scenario, or even if it's necessary.

add a comment |
We have a VB6 application using ADO and needed to update the SQL Server ODBC drivers to handle TLS 1.2 compliancy. I am able to query a varchar(max) field using the original {SQL Server} driver, but any newer ODBC driver will not return varchar(max) fields (13, 11, SQL Native Client 11, 10, etc.). All the other fields field types return fine with newer drivers, except the varchar(max).
I am setting my database connection string as follows:
PROVIDER=MSDASQL;Driver={ODBC Driver 13 for SQL Server};Server=server;DATABASE=dbname;UID=user;PWD=password;DataTypeCompatibility=80;MARS Connection=True;
Then executing the ADO recordset using:
Set recordset1 = gsSQLConn.Execute(strSQL, recordsaffected, adCmdText)
The SQL is
SELECT TABLE.NOTES AS [Value] From TABLE WHERE (((TABLE.NOTES) Is Not Null) AND ((TABLE.TABLE_ID)=#####))
where ##### is a valid integer ID for the table.
The return value shows as:
2 à
and is type 200 (adVarChar).
I am at a loss on this one, and not sure why I cannot get the newer ODBC drivers to read the varchar(max) fields. I did look into the SQLGetData function, but not quite sure how to get it working for my scenario, or even if it's necessary.

social.msdn.microsoft.com/Forums/windows/en-US/…?
– GSerg
Nov 19 '18 at 23:58
Thank you so much! The "garbage characters" nailed it. I was actually able to use SQLOLEDB (a little older) instead of MSOLEDBSQL without any problems. I previously was using MSDASQL to no avail, and even tried other providers (as I came from the DAO world with VB6).
– Tom
Nov 20 '18 at 16:38
add a comment |
We have a VB6 application using ADO and needed to update the SQL Server ODBC drivers to handle TLS 1.2 compliancy. I am able to query a varchar(max) field using the original {SQL Server} driver, but any newer ODBC driver will not return varchar(max) fields (13, 11, SQL Native Client 11, 10, etc.). All the other fields field types return fine with newer drivers, except the varchar(max).
I am setting my database connection string as follows:
PROVIDER=MSDASQL;Driver={ODBC Driver 13 for SQL Server};Server=server;DATABASE=dbname;UID=user;PWD=password;DataTypeCompatibility=80;MARS Connection=True;
Then executing the ADO recordset using:
Set recordset1 = gsSQLConn.Execute(strSQL, recordsaffected, adCmdText)
The SQL is
SELECT TABLE.NOTES AS [Value] From TABLE WHERE (((TABLE.NOTES) Is Not Null) AND ((TABLE.TABLE_ID)=#####))
where ##### is a valid integer ID for the table.
The return value shows as:
2 à
and is type 200 (adVarChar).
I am at a loss on this one, and not sure why I cannot get the newer ODBC drivers to read the varchar(max) fields. I did look into the SQLGetData function, but not quite sure how to get it working for my scenario, or even if it's necessary.

We have a VB6 application using ADO and needed to update the SQL Server ODBC drivers to handle TLS 1.2 compliancy. I am able to query a varchar(max) field using the original {SQL Server} driver, but any newer ODBC driver will not return varchar(max) fields (13, 11, SQL Native Client 11, 10, etc.). All the other fields field types return fine with newer drivers, except the varchar(max).
I am setting my database connection string as follows:
PROVIDER=MSDASQL;Driver={ODBC Driver 13 for SQL Server};Server=server;DATABASE=dbname;UID=user;PWD=password;DataTypeCompatibility=80;MARS Connection=True;
Then executing the ADO recordset using:
Set recordset1 = gsSQLConn.Execute(strSQL, recordsaffected, adCmdText)
The SQL is
SELECT TABLE.NOTES AS [Value] From TABLE WHERE (((TABLE.NOTES) Is Not Null) AND ((TABLE.TABLE_ID)=#####))
where ##### is a valid integer ID for the table.
The return value shows as:
2 à
and is type 200 (adVarChar).
I am at a loss on this one, and not sure why I cannot get the newer ODBC drivers to read the varchar(max) fields. I did look into the SQLGetData function, but not quite sure how to get it working for my scenario, or even if it's necessary.


edited Nov 19 '18 at 23:43


Sami
8,29231240
8,29231240
asked Nov 19 '18 at 23:41
TomTom
62
62
social.msdn.microsoft.com/Forums/windows/en-US/…?
– GSerg
Nov 19 '18 at 23:58
Thank you so much! The "garbage characters" nailed it. I was actually able to use SQLOLEDB (a little older) instead of MSOLEDBSQL without any problems. I previously was using MSDASQL to no avail, and even tried other providers (as I came from the DAO world with VB6).
– Tom
Nov 20 '18 at 16:38
add a comment |
social.msdn.microsoft.com/Forums/windows/en-US/…?
– GSerg
Nov 19 '18 at 23:58
Thank you so much! The "garbage characters" nailed it. I was actually able to use SQLOLEDB (a little older) instead of MSOLEDBSQL without any problems. I previously was using MSDASQL to no avail, and even tried other providers (as I came from the DAO world with VB6).
– Tom
Nov 20 '18 at 16:38
social.msdn.microsoft.com/Forums/windows/en-US/…?
– GSerg
Nov 19 '18 at 23:58
social.msdn.microsoft.com/Forums/windows/en-US/…?
– GSerg
Nov 19 '18 at 23:58
Thank you so much! The "garbage characters" nailed it. I was actually able to use SQLOLEDB (a little older) instead of MSOLEDBSQL without any problems. I previously was using MSDASQL to no avail, and even tried other providers (as I came from the DAO world with VB6).
– Tom
Nov 20 '18 at 16:38
Thank you so much! The "garbage characters" nailed it. I was actually able to use SQLOLEDB (a little older) instead of MSOLEDBSQL without any problems. I previously was using MSDASQL to no avail, and even tried other providers (as I came from the DAO world with VB6).
– Tom
Nov 20 '18 at 16:38
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384227%2funable-to-retrieve-varcharmax-fields-using-vb6-ado-on-sql-server-with-odbc-13%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384227%2funable-to-retrieve-varcharmax-fields-using-vb6-ado-on-sql-server-with-odbc-13%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
social.msdn.microsoft.com/Forums/windows/en-US/…?
– GSerg
Nov 19 '18 at 23:58
Thank you so much! The "garbage characters" nailed it. I was actually able to use SQLOLEDB (a little older) instead of MSOLEDBSQL without any problems. I previously was using MSDASQL to no avail, and even tried other providers (as I came from the DAO world with VB6).
– Tom
Nov 20 '18 at 16:38