Dim OraDatabase As Object '数据库对象
Dim OraDynaset As Object'动态集对象
Dim OraDatabase As Object’字段集对象
Set OraSession =CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase=OraSession.CreateDatabase
("Demo","scott/tiger",0&)'建立数据库连接
Set OraDynaset=OraDatabase.CreateDynaset("select*from
student",0&)'初始化动态集对象
’添加记录
'Begin an AddNew
OraDynaset.DbAddNew
OraDynaset.Fields("ID").value="1000"
’ID为列名
OraDynaset.DbUpdate'更新数据到表
’删除
OraDynaset.DbDelete
'修改
OraDynaset.DbEdit
OraDynaset.Fields("ID").value="101210"
OraDynaset.DbUpdate
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.ClickDim shkcode1 As String
Dim shimei1 As String
Dim inymd1 As String
Dim sqlstr As String
' Dim dr As DataRow
shkcode1 = DataGridView1.Rows(4).Cells(0).Value
shimei1 = DataGridView1.Rows(4).Cells(1).Value
inymd1 = DataGridView1.Rows(4).Cells(2).Value
sqlstr = " insert into EA_M1施设职员(shkcode,shimei,inymd) values ('" &shkcode1 &"','" &shimei1 &"','" &inymd1 &"')"
Dim connection As New OracleConnection("连接字符串")
Dim cmd As New OracleCommand(sqlstr, connection)
Try
connection.Open()
Dim rows As Integer = cmd.ExecuteNonQuery()
if rows >0 then
'说明执行成功了.可以做之后的 *** 作
end if
Catch E As System.Data.OracleClient.OracleException
connection.Close()
Throw New Exception(E.Message)
End Try
end sub
ps:建议去学学ADO.Net 不难的.
写个存储过程然后 循环
select a ,b into v_a ,v_b from table_name
update table_name set a =v_b ,b= v_a
commit
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)