ADO in VB.NET
Posted on 2002-05-20
im writing this very simple application in vb.net and i am trying to insert a record into an MS Access table using ADO.NET (2.7) and for the life of me can't figure out why this code gets an "unhandled error":
Dim conn As New OleDb.OleDbConnection()
Dim sql As String
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & System.Windows.Forms.Application.StartupPath & _
sql = "INSERT INTO hotlist (LAST) VALUES ('SMITH')"
Dim cmd As New OleDb.OleDbCommand(sql, conn)
cmd.ExecuteNonQuery() '<----error occurs here
i'm not sure im even coding this write. if anyone has a better solution to insert a record to an access database through code, let me know. thanks.