1949年日内瓦四公约:我正在学习VB但是有些问题不懂!
来源:百度文库 编辑:神马品牌网 时间:2024/05/05 09:24:32
Private Sub cmdEnter_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim UTIXING As String
If KeyAscii = 13 Then
Msg = "增添到数据库 ?" ' 定义信息。
Style = vbYesNo + vbCritical + vbDefaultButton2 ' 定义按钮。
Title = "确认新增" ' 定义标题。
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' 用户按下“是”。
MyString = "Yes" ' 完成某操作。
Adodc1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=jwl_dbf"
Adodc1.RecordSource = "select * from JWCK_BM" & _
" where js_dm >='" & "1" & "'" & " order by js_dm"
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset(0) = Text1
Adodc1.Recordset(1) = Text2
Adodc1.Recordset.Update
Text2 = ""
Text1 = ""
Text1.SetFocus
Else ' 用户按下“否”。
MyString = "No" ' 完成某操作。
Text2 = ""
Text1 = ""
Text1.SetFocus
End If
End If
End Sub
详细可参阅http://iask.sina.com.cn/b/4311164.html
的工程附件jwlsjk.rar
用最简单的Data控件就可以了
在按钮事件中输入
Data1.Recordset.AddnNew
Data1.Recordset("列1")=Text1.Text
Data1.Recordset("列2")=Text2.Text
Data1.Recordset.Update
即可
当然还要连接数据库和Data控件
不清楚的话再联系我吧~