我刚学
不知道你在说什么
不过以我非常有限的知识觉得
添加 修改 删除 数据很容易
以下代码直接复制既可用
dim strConnect as string
strConnect = "Provider=SQLOLEDB;User ID=sa;password=;database=数据库;server=服务器"
Private Sub Add()
Try
Dim conn3 As New OleDb.OleDbConnection(strConnect)
Dim da1 As New OleDb.OleDbDataAdapter
Dim com1 As New OleDb.OleDbCommand("insert AdminEmployee values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & cmb1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')", conn3)
da1.InsertCommand = com1
com1.Connection.Open()
com1.ExecuteNonQuery()
com1.Connection.Close()
MsgBox("添加成功", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox("Somethinsg worng " & ex.ToString)
End Try
End Sub
'-------------------------------------------
Private Sub Delete()
Try
Dim conn4 As New OleDb.OleDbConnection(strConnect)
Dim da1 As New OleDb.OleDbDataAdapter
Dim com2 As New OleDb.OleDbCommand("Delete From AdminEmployee where ID='" & TextBox1.Text & "'", conn4)
da1.DeleteCommand = com2
com2.Connection.Open()
com2.ExecuteNonQuery()
com2.Connection.Close()
MsgBox("删除成功", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox("Somethinsg worng " & ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Manage()
Try
Dim conn5 As New OleDb.OleDbConnection(strConnect)
Dim da As New OleDb.OleDbDataAdapter
Dim com3 As New OleDb.OleDbCommand("update AdminEmployee set Name ='" & TextBox2.Text & "',Address ='" & TextBox3.Text & "',Phone='" & TextBox4.Text & "',Email='" & TextBox5.Text & "',PostCard='" & TextBox6.Text & "',Position='" & cmb1.Text & "' where ID = '" & TextBox1.Text & "'", conn5)
da.UpdateCommand = com3
com3.Connection.Open()
com3.ExecuteNonQuery()
com3.Connection.Close()
MsgBox("修改成功", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox("系统发生错误,请确定操作正确!" & ex.ToString, MsgBoxStyle.Critical)
End Try
End Sub
[此贴子已经被作者于2005-1-19 12:11:33编辑过]