• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5112
  • Last Modified:

Insert data into Access database from VB 2005 form

I have a Visual Basic form where data is entered.  I need to insert this data into an Access database but I don't know the code.  I am a newbie at this.
0
MyTime2Live
Asked:
MyTime2Live
1 Solution
 
telefoniaCommented:
   '''''''############## Example code
        Dim oled1 As System.Data.OleDb.OleDbConnection
        Dim dir As String = System.Environment.CurrentDirectory & "\mybase.mdb"
       oled1 = New  System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dir & ";Persist Security Info=True")
Dim insert as string = "Insert Into table(col1,col2)values('" & texthere1 & "', '" & texthere2 & "')"
Dim insertcomand as new  System.Data.OleDb.Oledbcommand(insert, oled1)
oled1.open()
insertarcommand.executenowquery()
oled1.close()


       
0
 
MyTime2LiveAuthor Commented:
When I said I was a newbie I really meant a newbie so I had to work some to understand this answer.  It was accurate but a little above my level.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now