How do you insert label values to database? here is my code..

Imports System.Data.OleDb
Public Class frmemp
    Dim con As New OleDbConnection
    Dim dbAddNew As New OleDbCommand()
    Private Sub frmemp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As New DataSet
        Dim dt As New DataTable
        Dim da As New OleDbDataAdapter

        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\myDB.mdb"

        da = New OleDbDataAdapter("Select * From INFO_TABLE WHERE USER_ID LIKE '" & txtUSERID.Text & "'", con)
        DataGridView1.DataSource = dt.DefaultView

        Dim y As Integer = Val(DataGridView1.CurrentRow.Index)
        lblfn.Text = DataGridView1.Item(2, y).Value
        lblpro.Text = DataGridView1.Item(3, y).Value
        lblsa.Text = DataGridView1.Item(4, y).Value
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        lblTimeOut.Text = Format(System.DateTime.Now, "MM/dd/yyyy hh:mm:ss tt")
        Dim result As Integer
        result = MessageBox.Show("Are you sure you want to logout?", "ASC Billing System", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
        If result = vbYes Then

        End If

    End Sub

End Class

here is the window -

I need to insert lblTimeIn,lblTimeOut, and lblfn values to my database which is myDB after the Logout/Button1 is clicked..

How do you do this? I really dont have any knowledge about insert values in sql..

Please help..thanks..

Insert commands generally look like
INSERT INTO table VALUES(value1, value2, value3, etc) WHERE so criteriais true

So, in your case, you would have something like this:

Dim cmd As New OleDbCommand
cmd.Connection = connection
cmd.CommandText = "INSERT INTO tableName VALUES(?,?, ?)"
Dim para1 As New OleDbParameter
Dim para2 As New OleDbParameter
Dim para3 As New OleDbParameter
para1.Value = lblTimeIn.Text
para2.Value = lblTimeOut.Text
para3.Value = lblfn.Text

I'm out of practise with OleDb providers but hopefully I haven't forgotten too much and this is reasonably right. If the table you are inserting into has more than just those three columns you will need to alter the insert statement to be
INSERT INTO tableName(column1, column2, column3) VALUES(?,?, ?)

Hope that helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.