L?I: L?i 22018 "k? t? khng h?p l? cho di?n vin ?c t?"v?i gi tr? SQL Server 6,5

D?ch tiu ? D?ch tiu ?
ID c?a bi: 269011 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny


Khi m?t ODBC API ch?c nng nh SQLExecute g?i m?t th? t?c ?c lu tr? m c m?t cu?c g?i ?n sp_getbindtoken ho?c r?ng chy m?t kch ho?t c m?t cu?c g?i ?n sp_getbindtoken, b?n c th? nh?n th?y thng bo l?i sau:
DIAG [22018] [Microsoft] [ODBC SQL Server Driver] gi tr? k? t? khng h?p l? cho di?n vin ?c i?m k? thu?t (0)
SQLExecute tr? v? SQL_SUCCESS_WITH_INFO nhng bo co l?i trn.


Lo?i b? cc cu?c g?i ?n cc sp_getbindtoken h? th?ng lu tr? th? t?c, ho?c lo?i b? cc tham s? ?u ra.


Microsoft ? xc nh?n i?u ny l m?t v?n ? trong SQL Server 6.5.

L?i ny khng x?y ra v?i SQL Server 7.0 ho?c SQL Server 2000.


X?y ra l?i ny ch? v?i SQL Server 6.5, bao g?m c? Service Pack 1 thng qua 5a. L?i ny khng x?y ra khi cc th? t?c ?c lu tr? ?c g?i l t? isql ho?c khng c tham s? ?u ra.

Khi ?c g?i l t? m?t ?ng d?ng ODBC, th?c hi?n th? t?c ?c lu tr? tr? v? m?t gi tr? tr? l?i ch? ra s? thnh cng, nhng n t?o ra cc l?i ny v khng v?t qua l?i cc tham s? ?u ra. Cc cu?c g?i ODBC API SQLExecute tr? v? SQL_SUCCESS_WITH_INFO v thng bo l?i ? trn.

Cc b?c ? t?o l?i hnh vi

  1. T?o m?t b?ng, m?t th? t?c ?c lu v kch ho?t m?t trong qun r?u c s? d? li?u b?ng cch s? d?ng o?n m? SQL sau y:
    create table emp_table (emp_id int primary key,
                            emp_name varchar(80) not null )
    create trigger TR_emp_table_ins on emp_table
    for insert as
        declare @token_value varchar(255)
        exec master..sp_getbindtoken @token_value output
    create procedure test_proc_one
        @return_code int output,
        @error_code int output
        declare @token_value varchar(255)
        declare @max_emp_id int
        select @return_code = 13
        begin tran
        select @max_emp_id = max(emp_id) from emp_table
        if @max_emp_id is null
            select @max_emp_id = 1
            select @max_emp_id = @max_emp_id + 1
        insert into emp_table values(@max_emp_id, 'John Doe')
        if @@error <> 0
            raiserror('Insert into employee_list failed for emp_id %d', 16, -1, @max_emp_id)
            rollback tran
            select @return_code = -100
            select @error_code = -200
            commit tran
            select @return_code = 0
            select @error_code = 2
    end /* procedure test_proc_one */ 
  2. Ch?y o?n m? SQL sau bn trong isql. N nn ?c thnh cng v chn m?t hng vo bi ki?m tra b?ng, emp_table:
    declare @ret_value int
    declare @err_code int
    declare @string varchar(255)
    select @ret_value = 10
    select @err_code = 20
    exec test_proc_one @ret_value output, @err_code output
    select @string = 'test_proc_one set ret_value to ' + rtrim(convert(varchar(16), @ret_value))
                     + ' and err_code to ' + rtrim(convert(varchar(16), @err_code))
    print @string
    select * from emp_table
  3. G?i cho cc th? t?c ?c lu tr? cng m?t t? m?t ?ng d?ng ODBC b?ng cch s? d?ng o?n m? m?u sau. Cng m?t l?i c?ng c th? ?c sao chp b?ng cch s? d?ng cng c? ODBC th? nghi?m b?ng cch g?i cc ch?c nng ?c hi?n th? trong tr?nh t? gi?ng.
    	SQLRETURN rc;
    	SQLCHAR*  SQLStr = "{call test_proc_one(?,?)}";
       	SQLINTEGER nReturnCode = SQL_NTS;
    	SQLINTEGER nErrorCode = SQL_NTS;
    	SQLINTEGER cbReturnCode = SQL_NTS;
    	SQLINTEGER cbErrorCode = SQL_NTS;
    	/* Prepare the statement, bind parameters, and execute the statement */ 
    	rc = SQLPrepare(hStmt, SQLStr, SQL_NTS);
    	rc = SQLBindParameter(hStmt, 1, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 
    		                    0, 0, &nReturnCode, 0, &cbReturnCode);
    	rc = SQLBindParameter(hStmt, 2, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER,
    		                    0, 0, &nErrorCode, 0, &cbErrorCode);
    	rc = SQLExecute(hStmt);
    	do {
    	   rc = SQLMoreResults(hStmt);
    	} while (rc != SQL_NO_DATA);
  4. K?t qu? b?c ? trn nh n?c SQL 22018 v "k? t? khng h?p l? gi tr? cho ?c i?m k? thu?t di?n vin" tin nh?n v?i m?t m? tr? l?i c?a SQL_SUCCESS_WITH_INFO. Sau y l m?t m?u ODBC water ng nh?p:
    mssamp          163:166	EXIT  SQLExecute  with return code 1 (SQL_SUCCESS_WITH_INFO)
    		HSTMT               0x00cc2158
    		DIAG [22018] [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification (0) 

Thu?c tnh

ID c?a bi: 269011 - L?n xem xt sau cng: 22 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft SQL Server 6.5 Standard Edition
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
T? kha:
kbbug kbdatabase kbpending kbmt KB269011 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:269011

Cung cp Phan hi


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