May Allah's peace , mercy and blessing be upon you
how to add new record in ado classic
Sub AddRecord()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
' to Open the connection
conn.Open
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\NorthWind.mdb;"
' to Open the recordset
rs.Open "SELECT * FROM
Customers",conn, adOpenKeyset, adLockOptimistic
'to Add a new record
rs.AddNew
' to Specify the values for the fields
rs!CustomerId = "Mostafa"
rs!CompanyName = "ommah host"
rs!ContactName = "Ali"
rs!ContactTitle = "Sales"
rs!Address = "2st sidy gaber"
rs!City = "Alex"
rs!PostalCode = "11"
rs!Country = "egypt"
rs!Phone = "(02) 5559876"
rs!Fax = "(02) 5558908"
'to Save the changes you made to the
'to current record in the Recordset
rs.Update
'to For this example, just print out
'to CustomerId for the new record
Debug.Print rs!CustomerId
'to Close the recordset
rs.Close
End
Sub
Thank You
0 التعليقات:
إرسال تعليق