VB系统如何实现对access数据库添加删除,数据,在线等急 50
麻烦告诉我添加和删除功能的控件怎么谢,万分感谢!PrivateSubForm_Load()DimcnAsNewADODB.ConnectionDimrsAsNewADOD...
麻烦告诉我添加和删除功能的控件怎么谢,万分感谢!Private Sub Form_Load()Dim cn As New ADODB.ConnectionDim rs As New ADODB.RecordsetDim constr As StringDim a As Stringconstr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _"Data Source=" & App.Path & "\train.mdb"cn.Open constra = "select * from train "rs.Open a, cnms1.TextMatrix(0, 1) = "车次"ms1.TextMatrix(0, 2) = "出发站"ms1.TextMatrix(0, 3) = "到达站"ms1.TextMatrix(0, 4) = "出发时间"ms1.TextMatrix(0, 5) = "到达时间"ms1.TextMatrix(0, 6) = "票价"ms1.TextMatrix(0, 7) = "余票"Dim i As Integeri = 1Do While Not rs.EOF If (rs.Fields("start") = Form3.Combo4.Text) And (rs.Fields("over") = Form3.Combo5.Text) Then ms1.TextMatrix(i, 0) = i ms1.TextMatrix(i, 1) = rs.Fields("index") ms1.TextMatrix(i, 2) = rs.Fields("start") ms1.TextMatrix(i, 3) = rs.Fields("over") ms1.TextMatrix(i, 4) = rs.Fields("stime") ms1.TextMatrix(i, 5) = rs.Fields("otime") ms1.TextMatrix(i, 6) = rs.Fields("piaojia") ms1.TextMatrix(i, 7) = rs.Fields("yupiao") ms1.AddItem i + 1 i = i + 1 End Ifrs.MoveNextLoopms1.RemoveItem irs.Closecn.CloseEnd SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub ms1_Click()End Sub
展开
2个回答
展开全部
rs.open 之后
rs.AddNew
rs("字段名") = "内容"
rs.Update
=================
rs.Delete
rs.Update
rs.AddNew
rs("字段名") = "内容"
rs.Update
=================
rs.Delete
rs.Update
追问
添加是写在控件里面吗,删除要删除主键为条件怎么写。。
追答
添加写在 按钮单击事件里
rs.open "select * from 表 where 主键=值"
if rs.recordcount>0 then
rs.delete
rs.update
end if
rs.close
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询