vb.net增加修改删除 vbnet foreach

求VB.NET2010连接MDB数据库后 , 添加、修改和删除等写法示例引用 Microsoft ActiveX Data Objects 2.8 Library
或者加入microsoft ado data control
定义数据库连接
Dim Cnn As New ADODB.Connection
定义操作记录
Dim Res As New ADODB.Recordset
开始使用
If Res.State = 1 Then Res.Close
Res.CursorLocation = adUseClient
Res.Open "SELECT * From 发票表", Cnn, adOpenDynamic, adLockReadOnly
删除用res.Delete
添加用res.AddNew
res.Fields("序号") = Trim(Res.Fields("序号"))
...
res.Update
更新用Res.Update "序号", 111
列:
'写入产品信息
Sub WriteFP()
'On Error Resume Next
Dim SyBaseRes As New ADODB.Recordset
PB.value = https://www.04ip.com/post/0
Res.Open "SELECT Count(*) From ICSaleEntry INNER JOIN t_Item ON ICSaleEntry.FItemID = t_Item.FItemID INNER JOIN t_MeasureUnit ON ICSaleEntry.FUnitID = t_MeasureUnit.FMeasureUnitID", SQLServer, adOpenDynamic, adLockReadOnly
Text2.Text = "当前共 "Val(Res.Fields(0))"条数据"
PB.Max = Val(Res.Fields(0))
If Res.State = 1 Then Res.Close
Res.Open "SELECT ICSaleEntry.FDetailID AS 序号,ICSaleEntry.FInterID AS 物料编号, t_Item.FName AS 产品名称,ICSaleEntry.FAuxPrice AS 单价, ICSaleEntry.FAuxQty AS 数量,ICSaleEntry.FAmount AS 原币, ICSaleEntry.FStdAmount AS 本币,t_MeasureUnit.FName AS 单位 FROM ICSaleEntry INNER JOIN t_Item ON ICSaleEntry.FItemID = t_Item.FItemID INNER JOIN t_MeasureUnit ON ICSaleEntry.FUnitID = t_MeasureUnit.FMeasureUnitID", SQLServer, adOpenDynamic, adLockReadOnly
Do While Not Res.EOF
If SyBaseRes.State = 1 Then SyBaseRes.Close
SyBaseRes.Open "select * from 物料表 where 序号='"Res.Fields("序号")"'", Cnn, adOpenDynamic, adLockOptimistic
If SyBaseRes.EOF Then
Text2.Text = Text2.Text + vbCrLf + "正在添加: "Trim(Res.Fields("序号"))
SyBaseRes.AddNew
SyBaseRes.Fields("序号") = Trim(Res.Fields("序号"))
SyBaseRes.Fields("产品编号") = Trim(Res.Fields("物料编号"))
SyBaseRes.Fields("产品名称") = Trim(Res.Fields("产品名称"))
SyBaseRes.Fields("单价") = Trim(Res.Fields("单价"))
SyBaseRes.Fields("数量") = Trim(Res.Fields("数量"))
SyBaseRes.Fields("原币") = Trim(Res.Fields("原币"))
SyBaseRes.Fields("本币") = Trim(Res.Fields("本币"))
SyBaseRes.Fields("单位") = Trim(Res.Fields("单位"))
SyBaseRes.Fields("数据库名") = Trim(Text1.Text)
SyBaseRes.Update
Else
Text2.Text = Text2.Text + vbCrLf + "正在更新: "Trim(Res.Fields("序号"))
SyBaseRes.Update "序号", Trim(Res.Fields("序号"))
SyBaseRes.Update "产品编号", Trim(Res.Fields("物料编号"))
SyBaseRes.Update "产品名称", Trim(Res.Fields("产品名称"))
SyBaseRes.Update "单价", Trim(Res.Fields("单价"))
SyBaseRes.Update "数量", Trim(Res.Fields("数量"))
SyBaseRes.Update "原币", Trim(Res.Fields("原币"))
SyBaseRes.Update "本币", Trim(Res.Fields("本币"))
SyBaseRes.Update "单位", Trim(Res.Fields("单位"))
SyBaseRes.Update "数据库名", Trim(Text1.Text)
End If
PB.value = https://www.04ip.com/post/PB.value + 1
Res.MoveNext
DoEvents
Loop
If SyBaseRes.State = 1 Then SyBaseRes.Close
Set SyBaseRes = Nothing
End Sub
网络希望不要用ACCESS用ASA(就是sybase那个太强了)
如何用VB.net实现对Oracle数据库中数据的添加,删除,修改??急求程序代码,各位大神帮下忙你选中一条数据的时候把这条数据的ID也给取出来、点击修改把你去到的ID跟页面上三个TEXT框中的值同时转到后台进行修改、删除也是把你选中这行的ID传到SQL里
如何用vb.net查询、添加、删除、修改数据库(需要很详细的代码)?sQueryString是SQL(增删查改)语句
public

推荐阅读