| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1932 人关注过本帖
标题:vb 中 i,无法插入空行,行必须有一个列集值是怎么一回事呢?
只看楼主 加入收藏
a497391828
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-5-17
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:1 
vb 中 i,无法插入空行,行必须有一个列集值是怎么一回事呢?
第一次运行会说多不操作产生错误,请检查每一步的状态值。
再次运行就变成了无法插入空行,行必须有一个列集值
Option Explicit
Private Sub cmdExit_Click()
    Unload Me           '关闭购物车创建窗体
End Sub

Private Sub cmdOk_Click()
    On Error GoTo DoError
    Dim strSQL As String, objCom As Command
    If Trim(txtUser) = "" Then
        MsgBox "请输入客户姓名!", vbCritical, "创建购物车"
        txtUser = ""
        txtUser.SetFocus
    Else
        With Drug_Store.rsShoppingCars
            .AddNew
            .Fields("编号") = txtNumber
            .Fields("客户名") = txtUser
            .Fields("日期") = Date & " " & Format(Time, "hh:nn")
            .Update
            strSQL = "Create Table " & txtNumber _
                   & "( 编号 nchar(6) primary key, 数量 Smallmoney not null)"
            Set objCom = New Command
            Set objCom.ActiveConnection = Drug_Store.DataCon
             = strSQL
             = adCmdText
            objCom.Execute
            MsgBox txtUser & "购物车创建成功!编号:" & txtNumber, _
                    vbInformation, "创建购物车"
            Set objCom = Nothing
        End With
    End If
    Exit Sub
DoError:
    MsgBox Err.Description
End Sub

Private Sub cmdRefresh_Click()
    Dim strNum As String
    With Drug_Store.rsShoppingCars
        If .State = adStateClosed Then .Open
        If .RecordCount < 1 Then
            strNum = Format(Date, "yymmdd") & "00001"
        Else
            .MoveLast
            strNum = Right(.Fields("编号"), 5)
            strNum = Format(Val(strNum) + 1, "00000")
            strNum = Format(Date, "yymmdd") & strNum
        End If
    End With
    txtNumber = "T" & strNum
    txtUser = ""
    txtUser.SetFocus
End Sub

Private Sub Form_Load()
    Dim strNum As String
    With Drug_Store.rsShoppingCars
        If .State = adStateClosed Then .Open
        .Requery
        .Filter = "日期 Like '" & Date & "%'"
        If .EOF Then
            strNum = Format(Date, "yymmdd") & "00001"
        Else
            .MoveLast
            strNum = Right(.Fields("编号"), 5)
            strNum = Format(Val(strNum) + 1, "00000")
            strNum = Format(Date, "yymmdd") & strNum
        End If
    End With
    txtNumber = "T" & strNum
End Sub
搜索更多相关主题的帖子: 购物车 姓名 
2014-05-17 01:03
lowxiong
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:27
帖 子:653
专家分:3402
注 册:2008-5-7
收藏
得分:20 
以前也碰到过,忘记怎么解决的了,一般会是这几个方面导致的:
1,赋值类型和字段类型不符(如数字型赋值为文本型,日期型赋值为其他类型等)
2,赋值长度超过字段定义的长度(如字节型你赋值整形或双精度型,10个长度的字符赋值长度超过了)
3,有一个必填字段没有赋值,必填字段不能为null

2014-05-17 09:28
快速回复:vb 中 i,无法插入空行,行必须有一个列集值是怎么一回事呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017229 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved