Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

save information from form to acces mdb

$
0
0
hello everyone
what i am trying to do is to save infos like texboxs and checkboxs filled previously in a form in a recently created mdb file
i am still new to vb so i would appriciate your help
using vb 2010 express and access 2013
here is what i managed to do so far
Code:

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
        Dim logger As String = TextBox1.Text
        Dim databaseName As String = "C:\databases\" & logger & ".mdb"
        Dim tableName As String = "MyTable"
        Dim cn As New OleDbConnection
        Dim cmd As New OleDbCommand

        Dim cat As ADOX.Catalog = New ADOX.Catalog()

        cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & databaseName & ";Jet OLEDB:Engine Type=5")

        MessageBox.Show("Database Created Successfully")

        cat = Nothing
        Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & databaseName)

        cmd.CommandText = "INSERT into " & databaseName & " values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
        cmd.ExecuteNonQuery()

    End Sub

what i want to do is save the rest of info in the recently created database

thanks

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>