3、 Add方法
Add方法的目的是向数据库中添加一条新的CD信息,因此它打开的记录集要求能够更新。这就不能像OpenDB中那样仅用Open打开数据集。详细的代码见下面:
Private Sub Add(Id As String, Name As String, Author As String, Price As Currency, Information As String)
Dim NewConn As New ADODB.Connection
Dim NewRecordsetCD As New ADODB.Recordset
NewConn.Open "Provider=SQLOLEDB;DataSource=MUSE;Initial Catalog=Music;UserId=Wayne;Password=AbCdEfG"
NewRecordsetCD.Open "SELECT * FROM CD", NewConn, adOpenDynamic, adLockOptimistic
NewRecordsetCD.AddNew
NewRecordsetCD....[ 查看全文 ]