源程序
 strsql = "INSERT INTO KDB_Payment(BillID,paybank,UserName,BoundType,PaymentDate,VoucherId,VoucherWord,ACCTSum,Amount,MoneyType,ExchangeRate,GroupName,Note) VALUES ( "
            strsql = strsql & CInt(Trim(oItem.Text)) & "," _
                 & "'" & paybank & "'," _
                 & "'" & Trim(oItem.SubItems(1)) & "'," _
                 & "'" & Trim(oItem.SubItems(4)) & "'," _
                 & "'" & Voucherdate & "', " _
                 & "" & VoucherID & "," _
                 & "'" & VoucherWord & "'," _
                 & "" & ExchangeRate * Amount & "," _
                 & "" & Amount & "," _
                 & "'" & MoneyType & "'," _
                 & "" & ExchangeRate & "," _
                 & "'" & Trim(oItem.SubItems(8)) & "','" & Note & "')" '---问题在这一行
MsgBox strsql
        connPay.Execute strsql
在变量 note的值为""时,程序运行无误;有值时MsgBox 出来的字符无问题,但在监视变量工具中查看的值中note变量的值都被截掉了。是不是监视器对字符型变量有大小限制?程序错语提示输出:
Err.Number -2147217833
Err.HelpFile "C:\WINNT\Help\VBENLR98.CHM"
Err.Description "String or binary data would be truncated."
Err.HelpContext 1000440
Err.Source "Microsoft OLE DB Provider for SQL Server"
vb提示错误
实时错误 '2147217833 (80040e57)'
String or binary data world be truncated.

解决方案 »

  1.   

    Note在sql和VB中分别是什么类型的?
      

  2.   

    Note 是字符串吧? 大概有多长? 太长会被截断掉
      

  3.   

    如果是在sql中是char在VB中是string,可能有如下情况:判断一下,如果trim(Note)="" 那么 赋 null 给它还有是不是Note的长度大于了sql中该字段的长度
      

  4.   

    note在sql中,varchar(255)
    vb中,string相关的讨论在另一个贴子进行中。
    http://expert.csdn.net/Expert/topic/1638/1638625.xml?temp=.2595484
      

  5.   

    我在程序前面是这个赋值的。
    Note = Trim(CStr(ResSet.Fields("Note")))没用啊
    note在监视器中的值是:
    板蓝根原购买3350.00元,退药款840.00元,实2510.00元。