Adding records to MS ACCESS

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Experts,
I am just into dot net and i want simple code for adding records into Access
table (97) using oledb. There are no queries in the databases and there is
only one table:
Friends with the following fields: FriendID (AutoNumber) FirstName, LastName
and DateOfBirth

Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP

Thanks all
Regards
Manish Sawjiani
 
You create a new connection and command and then execute the command:

Public Function InsterRecord() As Integer
Dim conStr as String ="Provider=Microsoft.OLEDB.Jet.4.0;Data
Source=yourLocalDBpath"
Dim sqlStr as String = "SQL INSERT Statement Here"

Dim con As New OLEDB.OLEDBConnection(conStr)
Dim cmd As New OLEDB.OLEDBCommand(sqlStr, con)
Dim retVal as Integer
Try
con.Open()
Catch ex As OLEDB.OLEDBException
retVal =cmd.ExecuteNonQuery
Finally
con.Close()
End Try

Return retVal
End Function
 
¤ Hi Experts,
¤ I am just into dot net and i want simple code for adding records into Access
¤ table (97) using oledb. There are no queries in the databases and there is
¤ only one table:
¤ Friends with the following fields: FriendID (AutoNumber) FirstName, LastName
¤ and DateOfBirth
¤
¤ Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP

See if the following helps:

HOW TO: Use Microsoft Visual Basic .NET to Connect to a Microsoft Access Database and to Retrieve
Data
http://support.microsoft.com/default.aspx?scid=kb;en-us;821765


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top