鼠标挪到所要添加的位置点击右键选择添加就可以插入新的一行代码。
列表框控件(ListBox)和组合框控件(ComboBox)则有Clear方法,意思是清除项目。这个则是符合现代编程理念的。
分类: 电脑/网络 >>程序设计 >>其他编程语言问题描述:
Private Sub cmdOk_Click()
If Admin_Name.Text = "" Or Admin_PassWord.Text = "" Or Admin_RegPassWord.Text = "" Then
MsgBox "用户名或密码不能为空,请返回输入!", vbExclamation + vbOKOnly, "提示!"
Admin_Name.SetFocus
ElseIf Admin_PassWord.Text <>Admin_RegPassWord.Text Then
MsgBox "两次密码输入不一致,重新输入!", vbExclamation + vbOKOnly, "提示!"
Admin_PassWord.Text = ""
Admin_RegPassWord.Text = ""
Admin_PassWord.SetFocus
Else
Dim Conn As New ADODB.Connection
Dim StrSql As String
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &App.Path &"\Data\Hydata.mdb" &"Mode=ReadWritePersist Security Info=False"
'向数据库HYDATA里面的ADMIN表添加窗体上文本框里面的内容。这里应该怎么写呢?
'谢谢了
Conn.Close
End If
End Sub
================================
ACCESS名“HyData” 管理员表名:“Admin”里面的表头是:
Admin_ID,Admin_User,Admin_Pwd,Admin_HomeTel,Admin_Mobile
==================================
AddFrom窗体的文本框
Admin_Name,Admin_PassWord,Admin_RegPassword,Admin_HomeTel,Admin_Mobile.
=其中:Admin_PassWord,Admin_RegPassword 这两个判断两次密码是否一至。。
各位帮我看看。
解析:
xm= Request.Form("xm")
xb= Request.Form("xb")
ah= Request.Form("ah")
qqh= Request.Form("qqh")
set conn=Server.CreateObject("ADODB.Connection")
conn.open "DRIVER=Driver do Microsoft Access (*.mdb)DBQ="&Server.MapPath("data\db1.mdb")
into_db3 = "INSERT INTO 表3 ( xm, xb, ah ,qqh) VALUES('"+xm+"','"+xb+"','"+ah+"','"+qqh+"')"
conn3.Execute(into_db3)
conn3.Close
解释下:
上面的
xm= Request.Form("xm")
xb= Request.Form("xb")
ah= Request.Form("ah")
qqh= Request.Form("qqh") 是从表单中的文本框获取值
set conn=Server.CreateObject("ADODB.Connection")
conn.open "DRIVER=Driver do Microsoft Access (*.mdb)DBQ="&Server.MapPath("data\db1.mdb")
这两句是以字符串方式建立一个数据库连接
db1.mdb就是access数据库名字
data 是站点中用来存放数据库的文件夹,这儿路径一定得对才行.
into_db3 = "INSERT INTO 表3 ( xm, xb, ah ,qqh) VALUES('"+xm+"','"+xb+"','"+ah+"','"+qqh+"')" conn3.Execute(into_db3)这句就是将获得的值插入数据库了,表3是数据库中的一张表,插入时注意对应字段.
conn3.Close
关闭数据库连接, *** 作完成后关闭数据库连接.
当然上面的语句都得在一对定界符<% %>之间.
你自己做时帮相应字段改了就可以了.
还有不懂可以加QQ***********
“修改”按钮的程序 \x0d\x0aPrivate Sub cmdEdit_Click() \x0d\x0asql = "select * from 停时统计 where date = cdate('" &Text8.Text &"') and ycqk = '" &Combo1.Text &"'and id = '" &DataGrid1.Columns(2).CellText(DataGrid1.Bookmark) &"'" \x0d\x0ars.Open sql, dm, adOpenDynamic, adLockOptimistic \x0d\x0ars.Fields("id") = Text7.Text \x0d\x0ars.Fields("ycqk") = Combo1.Text \x0d\x0ars.Fields("date1") = Text1.Text \x0d\x0ars.Fields("time1") = Text2.Text \x0d\x0ars.Fields("date2") = Text3.Text \x0d\x0ars.Fields("time2") = Text4.Text \x0d\x0ars.Update \x0d\x0ars.Close \x0d\x0aEnd Sub \x0d\x0a\x0d\x0a'“删除”按钮的程序 \x0d\x0aPrivate Sub cmdDelete_Click() \x0d\x0astrFCode = DataGrid1.Columns(0).CellText(DataGrid1.Bookmark) \x0d\x0astrSCode = DataGrid1.Columns(2).CellText(DataGrid1.Bookmark) \x0d\x0astrCCode = DataGrid1.Columns(1).CellText(DataGrid1.Bookmark) \x0d\x0asql = "select * from 停时统计 where date='" &strFCode &"' and id='" &strSCode &"' and ycqk='" &strCCode &"'" \x0d\x0ars.Open sql, dm, adOpenDynamic, adLockOptimistic \x0d\x0ars.Delete \x0d\x0ars.Update \x0d\x0ars.Close \x0d\x0aEnd Sub \x0d\x0a\x0d\x0a'“增加”按钮的程序 \x0d\x0aPrivate Sub Command1_Click() \x0d\x0asql = "select * from 停时统计 order by id" \x0d\x0ars.Open sql, dm, adOpenDynamic, adLockOptimistic \x0d\x0ars.AddNew \x0d\x0ars.Fields("date") = Date \x0d\x0ars.Fields("id") = Text7.Text - 1 \x0d\x0ars.Fields("ycqk") = Combo1.Text \x0d\x0ars.Fields("date1") = Text1.Text \x0d\x0ars.Fields("time1") = Text2.Text \x0d\x0ars.Fields("date2") = Text3.Text \x0d\x0ars.Fields("time2") = Text4.Text \x0d\x0ars.Update \x0d\x0ars.Close \x0d\x0a\x0d\x0aWith Adodc1 \x0d\x0aAdodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &App.Path &"\db1.mdbPersist Security Info=False" \x0d\x0aAdodc1.RecordSource = "select * from 停时统计 where date = cdate('" &Text8.Text &"') and ycqk = '" &Combo1.Text &"' order by id" \x0d\x0aAdodc1.Refresh \x0d\x0aDataGrid1.Refresh \x0d\x0aEnd With \x0d\x0aEnd Sub欢迎分享,转载请注明来源:内存溢出
评论列表(0条)