doesn't save on the fly

Musab

Member
Joined
Apr 9, 2008
Messages
21
Programming Experience
1-3
Here is an image of the form
form1.jpg

My code :
VB.NET:
[COLOR="Blue"]
Imports System.Data.OleDb

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Db2000DataSet.Table1' table. You can move, or remove it, as needed.
        Me.Table1TableAdapter.Fill(Me.Db2000DataSet.Table1)

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Close()
    End Sub

    Private Sub btnnumfields_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnumfields.Click
        MsgBox(Me.Db2000DataSet.Table1.Count)
        'or
        'MsgBox(Me.Table1BindingSource.Count)
    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        Me.Table1BindingSource.MoveNext()
    End Sub

    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
        Me.Table1BindingSource.MovePrevious()
    End Sub

    Private Sub btnfirstfield_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirstfield.Click
        Me.Table1BindingSource.MoveFirst()
    End Sub

    Private Sub btnlastfield_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlastfield.Click
        Me.Table1BindingSource.MoveLast()
    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Me.Table1BindingSource.AddNew()
    End Sub

   [COLOR="Red"][B] Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Dim cn As OleDbConnection
        Dim cmd As OleDbCommand
        'Dim dr As OleDbDataReader
        Dim str As String
        Dim icount As Integer

        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Musab\My Documents\Visual Studio 2005\Projects\StudentDataBase\StudentDataBase\db2000.mdb")
        cn.Open()
        [COLOR="SeaGreen"]'str = "insert into Table1 values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"[/COLOR]
        str = "insert into Table1 values(" & "888" & ",'" & "testing8" & "','" & "12394" & "','" & "2109832" & "','" & "no notes" & "')"
        cmd = New OleDbCommand(str, cn)
        icount = cmd.ExecuteNonQuery
        MessageBox.Show(icount)
        cn.Close()

    End Sub[/B][/COLOR]
End Class[/COLOR]

So when I click on save it saves it but not on the fly, I have to restart the application.
 

Latest posts

Back
Top