VB连接的access数据库中有一个表cws,其中只存储了一个字段cws用来存储数字,如何将这个存储的数字赋值给一个int变量N呢?使用了一个data1控件,输入文本框已经关联了这个字段
语句该如何写?
dim N as integer
N=………………

解决方案 »

  1.   

    rs.Open "Select * From cws",conn,3,3
    N=rs("cws")
      

  2.   

    刚刚学数据库编程,楼上的大哥不好意思啊
    我可能没说明白,把代码全贴出来帮我看看
    Private Sub Command1_Click()
    Dim i As Integer
    Dim j As Integer
    Dim N As Integer
    rs.Open "Select * From3 cws", conn, 3, 3
    N = rs("cws")
       If Trim(Text1.Text) = "" Then '如果无输入
            MsgBox "请输入数量!", vbOKOnly + vbCritical, "错误"
      End If
      If Val(Text1.Text) > 208 Then
            MsgBox "对不起,本系统暂时最多只支持100个,请重新输入!", vbOKOnly + vbCritical, "错误"
            Text1.Text = ""
      End If
      If Val(Text1.Text) = 0 Then
            MsgBox "数量必须大于0!", vbOKOnly + vbCritical, "错误"
            Text1.Text = ""
      End If
     If Val(Text1.Text) > 0 And Val(Text1.Text) <= 208 Then '设置数量
          For i = 0 To N - 1
          form1.Command1(i).Visible = True
          Next i
          For j = N To 99
           form1.Command1(j).Visible = False
           Next j
           Data1.Recordset.Edit
           Unload Me
            End If
    End Sub
    这个代码需要如何修改?
    在线等…………
      

  3.   

    呵呵,自己试着已经搞定了
    就用N = Data1.Recordset!cws就可以赋值了
    不过,还是谢谢楼上那位兄弟啊。