hi experts
i m using ms access data base as back and in my new project,
this is my code

Imports System.Data.OleDb

Public Class st_name
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader
    Dim thismode As Integer

    Private Sub st_name_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'TODO: This line of code loads data into the 'Blood_bank_ds.st_name' table. You can move, or remove it, as needed.

        TextBox1.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            cmd = New OleDbCommand("", cn)
            If thismode = 0 Then
                cmd = New OleDbCommand("insert into st_name (" _
                                        & "st_name, " _
                                        & "us_code) values (" _
                                        & "'" & Trim(TextBox1.Text) & "',  " _
                                        & tus_code & ")", cn)
                cmd.CommandText = "update st_name set " _
                                        & "st_name = '" & Trim(TextBox1.Text) & "', " _
                                        & "us_code = " & tus_code & " where st_id = " & thismode

            End If
            'Dim icount As Integer
            'icount = cmd.ExecuteNonQuery

        Catch ex As Exception
        End Try
    End Sub

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

    End Sub

    Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
        thismode = DataGridView1.CurrentRow.Cells(0).Value
        TextBox1.Text = Trim(DataGridView1.CurrentRow.Cells(1).Value)
    End Sub
End Class

with this code insert command run properly and saved data sill be show in datagridview bu not save in mdb table , when i show in data table data is not shon

Assuming that your datagridview is databound, and it's datasource is Me.Blood_bank_ds.st_name.
Have you tried using a BindingSource object?

Public Class st_name
   Private source As New BindingSource
   Public Sub st_name_Load(....
      DataGridView1.DataSource = source
   End Sub

   Private Sub Button2_Click(.....

      'This will update the bindingsource, and because it's already tied to the datagrid the information in will be updated.
      source = Me.Blood_bank_ds.st_name
   End Sub
End Class
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.