JohnJackson
New member
- Joined
- Jun 1, 2016
- Messages
- 2
- Programming Experience
- 1-3
This is one of those I don't know what the heck I'm doing posts. It's my last/final project in VB.Net and we never learned how to access the local database in the code, we only learned how to access it using grid views in the toolbox.
Information:
Information:
- No errors but the values are not being added to the database.
- The database is a simple two column's with the names Number (Primary key, type number, set to not auto) and Conjecture (type checkbox)
VB.NET:
Public Class Form1
Dim connection As OleDb.OleDbConnection
Sub connectToDatabase()
connection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Goldbach.accdb;Persist Security Info=True")
connection.Open()
End Sub
Private Sub recordGoldbachNumber(ByVal number As Long, ByVal goldbach As Boolean)
Dim q As String = "INSERT INTO Goldbach([Number], Conjecture) VALUES (" + CStr(number) + ", " + CStr(goldbach) + ");"
Dim cmd As New OleDb.OleDbCommand(q, connection)
cmd.ExecuteNonQuery()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'GoldbachDataSet.Goldbach' table. You can move, or remove it, as needed.
Me.GoldbachTableAdapter.Fill(Me.GoldbachDataSet.Goldbach)
connectToDatabase()
recordGoldbachNumber(8, False)
End Sub
End Class