?????: ????? ????? ????? ODBC ???? ??? ???? ?????? SQL_NO_DATA_FOUND ??????? ??????? ANSI

?????? ????????? ?????? ?????????
???? ???????: 319243 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

???????

??? ??????? ?????? ????? ANSI ODBC? ????? ????? ????? ODBC ?? ???? ??? ???? ?????? SQL_NO_DATA_FOUND ????? ?? ?????? VARCHAR ?? CHAR ????? ????? ??? ????? ????? ???. ?? ???? ??????? ??? ??? ?????? ????? ??? ??? ???????? ?? ???? "?????". ???? ??????? ??? ??? ???????? ????? ?? ????? ????? ????? ?? ???? ?????? ???????? SQL_C_WCHAR.

?????

???? ??? ???? ODBC Driver Manager ????? ?? ?????? ??????? ?? ????? ??? ??? ?????? ??? ?????? ????? ??????? ??????? ?? ANSI ??? UNICODE.

????

??? ??? ???????? ??? ?????? ??? ???? ???? ???? ? Microsoft SQL Server 2000. ????? ?? ?????????? ???? ??? ??? ??????? ?????? ?????? ?? ???? ????? Microsoft ?????:
290211 INF: ????? ?????? ??? ???? ???? ???? ? SQL Server 2000

???? ??????

?? ????? ?? ??? ??????? ???? ?????? ? SQL_C_CHAR ????? ?? SQL_C_WCHAR.

?????

Microsoft ???? ???? ????? ?? ?????? Microsoft ???????? ?? ????? ??? ???????. ?? ????? ??? ??????? ???? ??? ?? Microsoft SQL Server 2000 Service Pack 3.

??????? ????

?? ???? ????????? ??????? ???? ?????? ?????? ????? ANSI ODBC ????? ??? ???????? ???? ?? ???? ??? ?????? ? SQL_C_WCHAR. ??? ???? Microsoft.NET ODBC ???? ??????? ??? ? SQL_C_WCHAR ???? ???????? ?? ????? ??? ??????? ??? ??? ?????? Microsoft ODBC.NET ???? ?? ?????? ????? ANSI. ???? ?? ???? Microsoft ODBC.NET ????? "NO_DATA" ??? ???? ??? ???????.

????? ????? ????? ??????

??????? ?????? ?????? ???? ???????:
  1. ?????? ???????? ????? ?????? ?????? ???? ?????? ??? ???:
    Create Table Test (ID integer, COL1 CHAR(10))
    Insert Into Test VALUES (1,'')
    					
  2. ????? ???????? C ???????:
    #include <windows.h>
    #include <stdio.h>
    #include <sql.h>
    #include <sqlext.h>
    
    int main(int argc, char* argv[])
    {
    	SQLCHAR*	theDiagState = new SQLCHAR[50];
    	SQLINTEGER	theNativeState;
    	SQLCHAR*	theMessageText  = new SQLCHAR[255];
    	SQLSMALLINT	iOutputNo;
    	SQLHENV		m_SQLEnvironment;
    	SQLHDBC		m_SQLConnection;
    	SQLHSTMT	m_SQLStatement;
    	SQLRETURN	iReturn;
    	long		lStrLen;
    	char		theData[1000];
    
    	//Connect.
    	iReturn = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&m_SQLEnvironment);
    	iReturn = SQLSetEnvAttr(m_SQLEnvironment,SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3,0);
    	iReturn = SQLAllocHandle(SQL_HANDLE_DBC,m_SQLEnvironment,&m_SQLConnection);
    
    	//CHANGE THE DSN NAME HERE.
    	char	szConnBuffer[1024];
    	short   cbOutConn;
    	char    szConnStr[255];
    
             strcpy(szConnStr,"DSN=YourANSIDSN;UID=YorUid;Pwd=YourPassword");
    	
    	iReturn= SQLDriverConnect(m_SQLConnection, NULL,
    (SQLTCHAR*) szConnStr,strlen(szConnStr), 
    (SQLCHAR*) szConnBuffer,1024, &cbOutConn, SQL_DRIVER_NOPROMPT);
    
    	if (iReturn != SQL_SUCCESS)
    	{
    		SQLGetDiagRec(SQL_HANDLE_DBC,m_SQLConnection,1,theDiagState,
    &theNativeState,theMessageText,100,&iOutputNo);
    	}
    
    	//Run query.
    	iReturn = SQLAllocHandle(SQL_HANDLE_STMT,m_SQLConnection,&m_SQLStatement);
    
    	//The Test table contains COL1 column which is set to empty for the first record.
    
    	iReturn = SQLExecDirect(m_SQLStatement, (SQLCHAR*) "Select ID,COL1 FROM Test",SQL_NTS);
    	iReturn = SQLFetch(m_SQLStatement);
    
    	iReturn = SQLGetData(m_SQLStatement,2,SQL_C_WCHAR,theData,100,&lStrLen);
    
    	//The problem does not occur if you bind the same column to SQL_C_CHAR.
    	//iReturn = SQLGetData(m_SQLStatement,2,SQL_C_CHAR,theData,100,&lStrLen);
    
    	if (iReturn != SQL_SUCCESS)
    	{
    		//iReturn will be 100 SQL_NO_DATA_FOUND here with NO other message.
    		int CheckHere;
    		CheckHere = 0;  //It will come here.
    		if (iReturn == SQL_NO_DATA_FOUND)
    		{
    			printf("SQL_NO_DATA_FOUND has been returned.\n Press Enter key to continue...\n");
    			getchar();
    		}
    		
    	}
    
    	//DISCONNECT.
    	iReturn = SQLFreeHandle(SQL_HANDLE_STMT,m_SQLStatement);
    	iReturn = SQLDisconnect(m_SQLConnection);
    	iReturn = SQLFreeHandle(SQL_HANDLE_DBC,m_SQLConnection);
    	iReturn = SQLFreeHandle(SQL_HANDLE_ENV,m_SQLEnvironment);
    
    	m_SQLStatement = NULL;
    	m_SQLConnection = NULL;
    	m_SQLEnvironment = NULL;
    
    	delete theMessageText; 
    	delete theDiagState;
    
    	return 1;
    }
    					
    ????? ??????? ???????:
    ??? ?? ????? SQL_NO_DATA_FOUND.
    ???? ??????? Enter ????????...

???????

???? ???????: 319243 - ????? ??? ??????: 19/?????/1434 - ??????: 7.0
????? ???
  • Microsoft Data Access Components 2.7
????? ??????: 
kbhotfixserver kbqfe kbdownload kbSQLServ2000sp3fix kbbug kbfix kbsqlserv2000presp3fix kbmt KB319243 KbMtar
????? ????
???: ??? ????? ??? ??????? ???????? ????? ?????????? ??????? ?????? ??? ??????? ?? ??? ??????? ?? ??????? ??? ??? ?? ???? ????????? ???? ??????? ???????(CTF) ?? ?? ???? ????? ????. ???? ?? ???? ?????????? ??? ???????? ???????? ???? ??? ?? ???????? ??????? ?? ??? ??????? ???????? ?? ??? ??????? ??????? ??? ?????? ?? ?????? ??? ???? ???????? ???????? ?? ????? ??????? ????? ????? ??????. ??? ?? ???????? ???????? ?? ????? ??? ????? ?? ???????? ?? ???? ????? ?? ?????. ?????? ??? ???? ?????????? ???? ?????? ?? ??? ????? ?? ??? ??? ?? ??????? ?? ??? ????? ?? ???? ????? ????? ?? ????? ??????? ???? ?? ???????? ?? ??? ???????.
???? ??? ????? ??????? ?????? ??????????319243

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com