我做的一个小程序,里面有一个增加记录的功能,我的代码如下:
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Then
MsgBox "数据不合法!", vbOKOnly + vbExclamation, "提示"
Else
Data1.Recordset.AddNew
Data1.Recordset.Fields("name") = Text1.Text
Data1.Recordset.Fields("id") = Text2.Text
Data1.Recordset.Fields("sex") = Text3.Text
Data1.Recordset.Fields("xy") = Text4.Text
Data1.Recordset.Fields("score") = CInt(Text5.Text)'这里为什么要用Cint(),而不用Int()呢?还有用Cstr(),不用Str()等?
Data1.Recordset.Update
MsgBox "增加记录成功,重启生效!", vbOKOnly + vbInformation, "增加记录" '为什么增加的记录要程序重新启动后才能看到,如果要实现马上生效,应该怎么做啊?
End If
Unload Form2
End Sub
我用的VB6.0企业版本没有data1.recorde.refresh这个方法啊???
在程序的运行的过程中如何实现数据库(Access 2003)的关闭和重启呢?
前提是程序不能关闭,限制用data控件.
|